我一直在使用 virtualenv + pip 进行 python 开发。我不确定发生了什么,但突然每当我尝试运行命令行工具或导入库时,我都会收到以下错误消息:
Traceback (most recent call last):
File "/Users/kyle/.virtualenvs/fj/bin/pip", line 4, in <module>
import pkg_resources
File "/Users/kyle/.virtualenvs/fj/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 698, in <module>
the platform/python version defined at initialization are added.
File "/Users/kyle/.virtualenvs/fj/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 701, in Environment
search_path = sys.path
File "/Users/kyle/.virtualenvs/fj/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 96, in get_supported_platform
'Environment', 'WorkingSet', 'ResourceManager',
File "/Users/kyle/.virtualenvs/fj/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 221, in get_build_platform
if provDarwin:
File "/Users/kyle/.virtualenvs/fj/lib/python2.6/distutils/__init__.py", line 14, 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'
据我所知,Python 试图distutils_path
在 Mac OSX 系统版本 Python 中找到,而不是我应该的 virtualenv 版本。
不知道为什么这突然开始发生。也许最近的 OSX 更新?另一种可能是我的硬盘快要死了,所以苹果给了我一个新的并运行了迁移助手。也许有些东西没有正确传输?