[AI]AI 챗봇 실습을 위한 가상환경 설정

사전 준비
1. 파이썬(3.7.8, 해당 버전으로 수행함)
※ 환경변수 체크 꼭 할 것

2. pycharm 설치

3. anaconda3 설치

4. Java SE Runtime Environment 8설치
※혹은 상위버전


※ 가상머신 생성은 Anaconda Prompt 에서 수행
가상머신 생성

 conda create -n <가상환경명> python=3.7 

※이후 activate <가상환경명> 입력

가상환경 활성화
 activate <가상환경명> 

모듈 설치

 pip install tensorflow==2.1 
 pip install konlpy 
 pip install PyKomoran 
 pip install gensim 
 pip install scikit-learn 
 pip install seqeval 
 pip install PyMySQL 
 pip install openpyxl 
 pip install pandas xlrd 
 pip install matplotlib 
 pip install flask 
 pip install requests 

※ 각 모듈에 대한 명칭은 별도로 표기하지 않음


인터프리터 설정

- 인터프리터는 생성한 가상머신의 python.exe 를 사용
- 설정 후 pycharm 에서>터미널>가상환경에서 pandas 설치 진행

※ 에러 Case

실습중,  tensorflow 와 protobuf의 호환성 문제가 있었는지 아래의 오류가 발생하였다

TypeError: Descriptors cannot not be created directly. If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0. If you cannot immediately regenerate your protos, some other possible workarounds are: 
 1. Downgrade the protobuf package to 3.20.x or lower. 
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower). 
 More information: 
https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

해결 방안 1
 pip install protobuf==3.20.* 
- protobuf downgrade 및 재설치
- 재설치해도 같은 오류 발생시 pip uninstall protobuf ==3.20.* 수행


해결 방안 2
 cd <가상 환경 경로>\Scripts 
 notepad activate.bat  
※ 파일이 존재 하지 않는 경우 새로 만든 후 계속

 @echo off 
 set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python 

위의 내용을 activate.bat 에 추가 후 저장

해결 방안 3
재설치
- 설치 방법을 정리하기 위해 새로운 가상환경을 작성하였는데, 놀랍게도 아무런 오류도 없었다.


댓글