Virtualenv shell错误

时间:2012-09-27 16:52:35

标签: python virtualenv pip

我刚刚在我的Mac上安装了virtualenv(使用Python 2.7.2),我按照指南进行了操作:http://virtualenvwrapper.readthedocs.org/en/latest/install.html

但是我每次启动shell时都会遇到以下错误:

stevedore.extension Could not load 'user_scripts': distribute
stevedore.extension distribute
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 62, in __init__
    invoke_kwds,
  File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 74, in _load_one_plugin
    plugin = ep.load()
  File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1953, in load
    if require: self.require(env, installer)
  File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1966, in require
    working_set.resolve(self.dist.requires(self.extras),env,installer))
  File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 565, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
DistributionNotFound: distribute
stevedore.extension Could not load 'project': distribute
stevedore.extension distribute
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 62, in __init__
    invoke_kwds,
  File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 74, in _load_one_plugin
    plugin = ep.load()
  File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1953, in load
    if require: self.require(env, installer)
  File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1966, in require
    working_set.resolve(self.dist.requires(self.extras),env,installer))
  File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 565, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
DistributionNotFound: distribute
stevedore.extension Could not load 'user_scripts': distribute
stevedore.extension distribute
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 62, in __init__
    invoke_kwds,
  File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 74, in _load_one_plugin
    plugin = ep.load()
  File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1953, in load
    if require: self.require(env, installer)
  File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1966, in require
    working_set.resolve(self.dist.requires(self.extras),env,installer))
  File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 565, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
DistributionNotFound: distribute

我不知道它是否影响了这个问题,但我使用的是ZSH。

我尝试通过pip安装stevedore(sudo pip install stevedore),但是我收到以下错误:

sudo sh setuptools-0.6c11-py2.7.egg
Processing setuptools-0.6c11-py2.7.egg
removing '/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg' (and everything under it)
Copying setuptools-0.6c11-py2.7.egg to /Library/Python/2.7/site-packages
setuptools 0.6c11 is already the active version in easy-install.pth
Installing easy_install script to /usr/local/bin
Installing easy_install-2.7 script to /usr/local/bin

Installed /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11
TXSLs-MacBook-Pro% sudo pip install stevedore --upgrade
Requirement already up-to-date: stevedore in /Library/Python/2.7/site-packages
Downloading/unpacking distribute (from stevedore)
  Running setup.py egg_info for package distribute

Installing collected packages: distribute
  Running setup.py install for distribute
    Before install bootstrap.
    Scanning installed packages
    Setuptools installation detected at /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg
    Egg installation
    Patching...
    Renaming /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg into /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg.OLD.1348764450.4
    Patched done.
    Relaunching...
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    NameError: name 'install' is not defined
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build/distribute/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-FAPgYH-record/install-record.txt --single-version-externally-managed:
    Before install bootstrap.

Scanning installed packages

Setuptools installation detected at /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg

Egg installation

Patching...

Renaming /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg into /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg.OLD.1348764450.4

Patched done.

Relaunching...

Traceback (most recent call last):

  File "<string>", line 1, in <module>

NameError: name 'install' is not defined

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build/distribute/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-FAPgYH-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build/distribute
Storing complete log in /Users/txsl/Library/Logs/pip.log

我手动安装了setuptools,因为我无法通过pip安装任何东西。

这里出了什么问题,我该如何解决?互联网似乎没有很多装卸工具的错误案例。我觉得此刻相当困难!

非常感谢!

4 个答案:

答案 0 :(得分:20)

我也使用zsh并遇到了类似的问题。我解决了这个问题:

sudo pip install virtualenv virtualenvwrapper

我在Ubuntu 12.04中安装了包python-pip

答案 1 :(得分:17)

根据您收到的错误,您似乎遇到以下错误:install glitch when using pip + virtualenv

使用-distribute开关时会产生此问题。修复是(没有使用--distribute重新运行virtualenv):

source bin/activate
wget http://python-distribute.org/distribute_setup.py
python distribute_setup.py

答案 2 :(得分:7)

有相同的错误消息,升级setuptools解决了我的问题。

pip install --upgrade setuptools

我在这个帖子中找到了信息:http://blog.gmane.org/gmane.comp.python.virtualenv/month=20131001

答案 3 :(得分:4)

升级到OSX Mavericks后我遇到了同样的问题。我通过全局安装分发来修复它。

sudo pip install distribute

我首先停用了当前的virtualenv。