60cod 2024. 6. 11. 14:30

1. python interpreter 추가

가상환경에 설치한 파이썬exe파일 추가, 선택

 

2. 가상환경 생성

프로젝트 하위에서 

python -m venv {가상환경이름}

 

3. 활성화

cd {가상환경이름}/Scripts
activate.bat

 

서버에서 가상환경 실행하려면

source venv/bin/activate

activate 있는 경로도 다름!

 

4. 모듈 설치 방법

그냥 설치하려고 하면 아래 에러 발생함.

AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?

원인: Due to the removal of the long-deprecated pkgutil.ImpImporter class, the pip command may not work for Python 3.12.x.

참고: https://stackoverflow.com/questions/77364550/attributeerror-module-pkgutil-has-no-attribute-impimporter-did-you-mean

 

파이썬 3.12 버전에서 pip은 아래와 같이 설치해야 한다.

python -m ensurepip --upgrade
python -m pip install --upgrade setuptools
python -m pip install {모듈이름}