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库路径:

<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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值