文章目录
一、Pyhon包的查找位置
bash
▶ [~]$ 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
▶ [~]$
或者另一种更加简洁的方式:
bash
python -c "import site; print(site.getsitepackages())"
二、某个Python特定包的查找位置
.path 识别特定包的位置
bash
python -c "import setuptools as _; print(_.__path__)"
.file 识别特定模块的位置
bash
python -c "import setuptools as _; print(_.__file__)"
pip show <package> 显示debian风格的包装信息:
bash
pip show numpy