为什么我的python安装程序可以识别/Library/Python/2.7/site-packages/? [英] Why does my python installation recognize /Library/Python/2.7/site-packages/?

查看:177
本文介绍了为什么我的python安装程序可以识别/Library/Python/2.7/site-packages/?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Homebrew安装了Python.我希望此python安装仅识别一个site-pakages目录-/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

I have installed Python using Homebrew. I would like for this installation of python to recognize only one site-pakages directory -- /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

但是,当我启动python shell并给出命令print [f for f in sys.path if f.endswith('packages')]时,我得到以下输出:

However, when I start the python shell and give the command print [f for f in sys.path if f.endswith('packages')] I get the following output:

['/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/Library/Python/2.7/site-packages']

为什么/Library/Python/2.7/site-packages坐在那里的尽头? Python的Homebrew安装程序不应该在/usr/local/???下只有一个主site-packages目录吗?

Why is /Library/Python/2.7/site-packages sitting at the end there? Shouldn't the Homebrew installation of Python have just one main site-packages directory under /usr/local/ ???

我正在使用virtualenv -但这是在我有机会安装virtualenv之前,使用自制软件重新安装python之后发生的.另外,我对它为什么会发生感兴趣,而不是我应该如何解决它.

I am using virtualenv -- but this is occurring after a fresh install of python using homebrew before I have even had a chance to install virtualenv. Also, I'm interested in why it is happening, not on what I should do to get around it.

推荐答案

为此创建了一个堆栈溢出帐户,因为我对此非常恼火.实际上,我在sys.path中无意中有一个额外的"/Library/Python/2.7/site-packages"错误.

Created a stack overflow account just for this, since I was so annoyed by it. I actually had a bug inadvertently caused by that extra "/Library/Python/2.7/site-packages" in the sys.path

研究它使我想到了这一点: http://bugs.python.org/issue4865

Researching it led me to this: http://bugs.python.org/issue4865

tl; dr:据我所知,他们会在那儿走那条路,以帮助安装了Apple运送的python软件包的人,但是后来会尝试在其他版本的python中使用这些软件包(例如那些由自制软件,macports等使用).

tl;dr: From what I can tell, they throw that path in there to help people that installed packages for the apple-shipped python, but then later would try to use those packages in other versions of python (like the ones used by homebrew, macports, etc).

这篇关于为什么我的python安装程序可以识别/Library/Python/2.7/site-packages/?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆