Computer >> 컴퓨터 >  >> 프로그램 작성 >> Python

파이썬 모듈은 어디에 저장됩니까?


Python 모듈은 일반적으로 Python 폴더의 /lib/site-packages에 저장됩니다. 모듈을 가져올 때 Python이 검사하는 디렉토리를 보려면 다음을 기록할 수 있습니다.

>>> import sys
>>> print sys.path
['', 'C:\\Python27', 'C:\\Python27\\Lib\\site-packages', 'C:\\Python27\\Lib', 'C:\\Python27\\DLLs', 'C:\\Python27\\Lib\\lib-tk', 'C:\\Python27\\Scripts', 'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\site-packages\\win32', 'C:\\Python27\\lib\\site-packages\\win32\\lib', 'C:\\Python27\\lib\\site-packages\\Pythonwin']

python -v 명령을 사용하여 스크립트(예:hello.py)가 사용하는 개별 모듈이 시스템에서 상주하는 위치를 나열할 수도 있습니다. 예를 들어,

$ python -v hello.py
PS C:\Users\Ayush> echo 'import scrapy' > hello.py
PS C:\Users\Ayush> python -v hello.py
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# C:\Python27\Lib\site.pyc matches C:\Python27\Lib\site.py
import site # precompiled from C:\Python27\Lib\site.pyc
# C:\Python27\Lib\os.pyc matches C:\Python27\Lib\os.py
...
...