【问题标题】:Virtualenv shell errorsVirtualenv 外壳错误
【发布时间】:2012-09-27 16:52:34
【问题描述】:

我刚刚在我的 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 (sudo pip install stevedore) 安装 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 安装任何东西。

这里出了什么问题,我该如何解决?互联网上似乎没有很多装卸工错误的案例。我现在感觉有点卡住了!

非常感谢!

【问题讨论】:

    标签: python virtualenv pip


    【解决方案1】:

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

    sudo pip install virtualenv virtualenvwrapper
    

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

    【讨论】:

    • 是的,成功了!就我而言,我使用自制软件将 python 2.7.3 升级到 python 2.7.5。之前在 python 2.7.3 中创建的虚拟环境也会有同样的问题。关键是停用该虚拟环境,然后为系统范围的 python 升级 virtualenv + virtualenvwrapper,这正是 Marcos 上面建议的。奇迹般有效!我用过: sudo pip install --upgrade virtualenv virtualenvwrapper
    • pip install --upgrade virtualenv virtualenvwrapper(注意 --upgrade)在升级到 Mavericks 然后通过 Homebrew 升级 Python 后为我工作。
    • 升级到 Ubuntu 14.04 后这对我有用
    【解决方案2】:

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

    问题是在使用 -distribute 开关时产生的。修复方法是(无需使用 --distribute 重新运行 virtualenv):

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

    【讨论】:

    • 我卡在第一行! :source bin/activate source: no such file or directory: bin/activate
    • 要执行该行,您需要确保已将目录更改为创建 virtualenv 的位置。因此,如果您在用户配置文件中创建了一个名为 vetest 的虚拟环境,则需要在执行该命令之前键入以下内容: cd ~/vetest 然后您将键入... source bin/activate
    • 等等,我需要为我创建的每个 virtualenv 执行此操作吗?我实际上还没有设置任何东西。
    • 答案有两个。您可以在没有 --distribute 选项的情况下卸载并重新安装。或者你必须每次都这样做。
    • 酷。抱歉没用,但你介意带我卸载它吗?我对此不是很有信心!我宁愿重新安装也不愿每次都这样做!
    【解决方案3】:

    有同样的错误信息,升级 setuptools 为我解决了这个问题。

    pip install --upgrade setuptools
    

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

    【讨论】:

    • 为我工作。我做了 sudo pip install --upgrade setuptools,然后 sudo uninstall virtualenv 和 sudo uninstall virtualenvwrapper,然后用 sudo pip install virtualenv virtualenvwrapper 重新安装它们。在那之后就像一个魅力。
    【解决方案4】:

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

    sudo pip install distribute
    

    我首先停用了我当前的 virtualenv。

    【讨论】:

    • 这也为我在小牛队修复了它。
    猜你喜欢
    • 2018-09-19
    • 1970-01-01
    • 1970-01-01
    • 2011-04-26
    • 2017-10-08
    • 2013-02-17
    • 2011-05-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多