python 中 dist-packages 和 site-packages 的區別
site-packages 和 dist-packages 的區別
dist-packages is a Debian-specific convention that is also present in its derivatives, like Ubuntu. Modules are installed to dist-packages when they come from the Debian package manager into this location:/usr/lib/python2.7/dist-packages
dist-packages 是 Debian特定慣例,這也存在於像是ubuntu上(ubuntu 是從 debian衍生來的)。 如果使用Debian軟體管理器安裝, 模組將被安裝到 dist-packages
檢視python庫路徑:
from distutils.sysconfig import get_python_lib
print(get_python_lib())
Since easy_install and pip are installed from the package manager, they also use dist-packages, but they put packages here: /usr/local/lib/python2.7/dist-packages
自從 easy_install 和 pip (注: 是python的軟體管理其,python有許許多多的軟體) 使用,他們也使用 dist-packages,但是 路徑是:/usr/local/lib/python2.7/dist-packages
根據現實場景:
sudo apt-get install 安裝的package存放在 /usr/lib/python2.7/dist-packages目錄中
pip 或者 easy_install安裝的package存放在/usr/local/lib/python2.7/dist-packages目錄
手動從原始碼安裝的package存放在site-packages目錄中
順帶說下包管理工具
Python的包管理工具常見的有easy_install, setuptools, 還有pip, distribute可以看到distribute是setuptools的替代方案,pip是easy_install的替代方案. 而setuptools 和 easy_install 已經越來越不被維護了,所以建議大家試用他們的替代版, 而如果要說 distribute 和 pip 的區別,那麼就是pip 的底層實現呼叫了 distribute 或者 setuptools