文章目录
- 一、Pyhon包的查找位置
- 二、某个Python特定包的查找位置
- 参考
一、Pyhon包的查找位置
▶ [~]$ python -m site
sys.path = ['/home/wangji','/usr/lib/python310.zip','/usr/lib/python3.10','/usr/lib/python3.10/lib-dynload','/home/wangji/.local/lib/python3.10/site-packages','/usr/local/lib/python3.10/dist-packages','/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/wangji/.local' (exists)
USER_SITE: '/home/wangji/.local/lib/python3.10/site-packages' (exists)
ENABLE_USER_SITE: True
▶ [~]$
或者另一种更加简洁的方式:
python -c "import site; print(site.getsitepackages())"
二、某个Python特定包的查找位置
.__path__ 识别特定包的位置
python -c "import setuptools as _; print(_.__path__)"
.__file__ 识别特定模块的位置
python -c "import setuptools as _; print(_.__file__)"
pip show <package> 显示debian风格的包装信息:
pip show numpy
参考
- Ubuntu 下 python 包寻找路径的问题