无法使用酿造的python 2.7 pip在OS X 10.8中安装virtualenv [英] Can't pip install virtualenv in OS X 10.8 with brewed python 2.7
问题描述
当尝试使用酿造的python安装virtualenv时,出现以下错误:
When trying to install virtualenv using a brewed python, I get the following error:
$ pip install virtualenv
Requirement already satisfied (use --upgrade to upgrade): \
virtualenv in /Library/Python/2.7/site-packages/virtualenv-1.9.1-py2.7.egg
Cleaning up...
因此,很明显pip正在某种程度上查找系统python文件夹,而不是在/usr/local中编写的文件夹.如何避免这种情况?
So clearly pip is somehow looking into the system python folder instead of the brewed one in /usr/local. How can I avoid this?
冲泡医生没有发现任何问题,并且路径优先级设置为"ok".
The brew doctor finds no problems, and the path priority is set ok.
我试图从系统python中删除virtualenv软件包, 所以我可以用酿造的pip安装virtualenv. 但是后来我无法创建virtualenvs,因为出现了这个错误:
I tried to remove the virtualenv package from the system python, so I could install virtualenv with the brewed pip. But then I could not create virtualenvs, as I got this error:
$ virtualenv datatransfer/
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: virtualenv==1.9.1
所以我还没有避免使用系统virtualenv.
So I have not managed to avoid the system virtualenv.
我做错了什么?
推荐答案
我遇到了同样的问题,并设法通过卸载任何Brew版本的Python和virtualenv来解决了该问题
I had the same problem and I managed to solve it by uninstalling any brew versions of Python and virtualenv
brew uninstall python
brew uninstall pyenv-virtualenv
手动将我在/usr/local/bin
下找到的所有virtualenv *文件移动到另一个文件夹
Manually moving all the virtualenv* files I found under /usr/local/bin
to another folder
sudo mkdir /usr/local/bin/venv-old
sudo mv /usr/local/bin/virtualenv* /usr/local/bin/venv-old/
打开一个新的终端选项卡,并仔细检查我是否处于干净状态
Opening a new terminal tab and double-checking that I'm in a clean state
which python # => /usr/bin/python
which virtualenv # => virtualenv not found
然后使用推荐的方法干净地安装Python和virtualenv(wrapper)(此处和此处 ):
And installing Python and virtualenv(wrapper) cleanly using the recommended method (here and here):
brew install python --with-brewed-openssl
# Open a new terminal tab now (to access /usr/local/bin/python)
pip install virtualenv
pip install virtualenvwrapper
这篇关于无法使用酿造的python 2.7 pip在OS X 10.8中安装virtualenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!