Python3 使用 PIP (PIP3) 安裝套件,套件安裝的路徑在哪裡呢? (環境:Debian、Ubuntu Linux)
Python3 PIP3 套件安裝在哪裡?
使用者直接使用 pip3 install 的話,預設會在自己目錄下的 ~/.local 裡面,執行檔會在 ~/.local/bin/ 裡面。
如何知道這些路徑,可以用此 Library:30.14. site — Site-specific configuration hook — Python 3.7.0 documentation
- $ python3 -m site --user-base
/home/user/.local - $ python3 -m site --user-site
/home/user/.local/lib/python3.5/site-packages
使用 python3 -m site 可以查看更多的資訊:
- $ python3 -m site
sys.path = [
'/home/user',
'/usr/lib/python35.zip',
'/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu',
'/usr/lib/python3.5/lib-dynload',
'/home/user/.local/lib/python3.5/site-packages',
'/usr/local/lib/python3.5/dist-packages',
'/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/user/.local' (exists)
USER_SITE: '/home/user/.local/lib/python3.5/site-packages' (exists)
ENABLE_USER_SITE: True - $ python -m site # Python 2 sys.path = [
'/home/user', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib /python2.7/dist-packages',
'/usr/lib/pymodules/python2.7',
]
USER_BASE: '/home/user/.local' (exists)
USER_SITE: '/home/user/.local/lib/python2.7/site-packages' (doesn't exist)
ENABLE_USER_SITE: True