본문 바로가기
개발이야기/python

python 가상환경 구성 site

by adrian7 2023. 1. 3.

이 모듈은 초기화 중에 자동으로 임포트 됩니다. 인터프리터의 -S 옵션을 사용하여 자동 임포트를 억제할 수 있습니다.

 

1. 명령 줄과 환경 — Python 3.10.9 문서

1. 명령 줄과 환경 CPython 인터프리터는 명령 줄과 환경에서 다양한 설정을 찾습니다. CPython 구현 상세: 다른 구현의 명령 줄 체계는 다를 수 있습니다. 자세한 내용은 대안 구현들 참조하십시오. 1

docs.python.org

 

“pyvenv.cfg”라는 파일이 sys.executable의 한 디렉터리 위에 있으면,

sys.prefix와 sys.exec_prefix가 그 디렉터리로 설정되고, site-packages도 검사됩니다 

import sys

#sys.executable python 실행
print("sys.executable :: " + sys.executable)

#sys.prefix
print("sys.prefix :: " + sys.prefix)

#sys.exec_prefix
print("sys.exec_prefix :: " + sys.exec_prefix)

 

실행 결과 전부 가상 환경 경로로 지정되어 있다.

/Users/adrian7/python-code/aa/aa.py 
sys.executable :: /Users/adrian7/python-code/aa/venv/bin/python
sys.prefix :: /Users/adrian7/python-code/aa/venv
sys.exec_prefix :: /Users/adrian7/python-code/aa/venv

 

“pyvenv.cfg” 파일내용

home = /usr/local/opt/python@3.10/bin
include-system-site-packages = false
version = 3.10.9

include-system-site-packages = true 이면 site-packages 를 검색하지 않는다.

 

pyvenv.cfg 파일안에  아래 내용도 설정이 가능하다.

implementation = 
virtualenv =
base-prefix = 
base-exec-prefix = 
base-executable =

'개발이야기 > python' 카테고리의 다른 글

ModuleNotFoundError: No module named 'mysql' in Python  (0) 2023.01.02