在Virtualenv中使用Python的Pip

时间:2011-11-22 13:01:29

标签: python heroku virtualenv pip

我一直在使用Heroku的雪松堆栈与Python,没有任何错误。但是,今天,当我决定在我的virtualenv通过sudo bin/pip install -r requirements更新我的依赖本地时,我收到了以下错误:

Traceback (most recent call last):
  File "/Users/alex/Desktop/dev/warren/warren/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/Users/alex/Desktop/dev/warren/warren/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 698, in <module>
  File "/Users/alex/Desktop/dev/warren/warren/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 701, in Environment
  File "/Users/alex/Desktop/dev/warren/warren/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 96, in get_supported_platform
  File "/Users/alex/Desktop/dev/warren/warren/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 221, in get_build_platform
  File "/Users/alex/Desktop/dev/warren/warren/lib/python2.6/distutils/__init__.py", line 16, in <module>
    exec(open(os.path.join(distutils_path, '__init__.py')).read())
IOError: [Errno 2] No such file or directory: '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/__init__.py'

我怀疑这与我升级到Lion有关(正如this question指出的那样),但正如我在问题中提到的那样,我也更新了Xcode,但问题仍然存在。

当我尝试cd进入上述目录时,没有__init__.py个文件,实际上根本没有.py个文件,只有.pyo和{{1文件。

1 个答案:

答案 0 :(得分:4)

您收到的错误消息是由于virtualenv为您的系统python创建的链接。你现在想破坏virtualenv并重新创建它。为了摧毁它,你需要:

rm -r bin
rm -r include
rm -r lib
rm .Python

然后你应该可以重新创建你的virtualenv然后pip安装你的requirements.txt