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庫路徑:
<code class="language-python hljs has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-keyword" style="margin: 0px; padding: 0px; color: rgb(0, 0, 136); box-sizing: border-box;">from</span> distutils.sysconfig <span class="hljs-keyword" style="margin: 0px; padding: 0px; color: rgb(0, 0, 136); box-sizing: border-box;">import</span> get_python_lib print(get_python_lib())</code><ul class="pre-numbering" style="margin: 0px; padding: 6px 0px 40px; box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="margin: 0px; padding: 0px 5px; box-sizing: border-box;">1</li><li style="margin: 0px; padding: 0px 5px; box-sizing: border-box;">2</li></ul>
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
轉載自:http://blog.csdn.net/huiseguiji1/article/details/45111891