Where are the python modules stored?

PythonServer Side ProgrammingProgramming

Python Modules are usually stored in /lib/site-packages in your Python folder. If you want to see what directories Python checks when importing modules, you can log the following:

>>> 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']

You can also list where individual modules being used by a script(say hello.py) reside on the system using the python -v command. For example,

$ 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
Published on 20-Dec-2017 11:45:25