Turbogears:更新到Mac OS X 10.6后无法启动paster
在更新到Mac OS X 10.6后,我不得不切换回Python 2.5,才能让虚拟环境正常工作。但是我还是无法启动我的Turbogears项目。Paster给出了这个错误:
Traceback (most recent call last):
File ".../tg2env/bin/paster", line 5, in <module>
from pkg_resources import load_entry_point
File ".../tg2env/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 657, in <module>
File ".../tg2env/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 660, in Environment
File ".../tg2env/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 55, in get_supported_platform
File ".../tg2env/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 186, in get_build_platform
File ".../tg2env/lib/python2.5/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.5/lib/python2.5/distutils/__init__.py'
有什么想法吗?谢谢。
3 个回答
0
你为什么需要切换回2.5版本才能让virtualenv正常工作呢?我已经升级到10.6,并且在Python 2.6中愉快地使用virtualenv。
0
可能你安装的是2.6版本的发行版。请在你的终端中运行以下命令:
defaults write com.apple.versioner.python Version 2.5
export VERSIONER_PYTHON_VERSION=2.5
sudo easy_install virtualenv
看看第二行,这个命令应该会在当前的终端会话中切换Python的版本。
dgl@dgl:~/ > python
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
...
dgl@dgl:~/ > export VERSIONER_PYTHON_VERSION=2.5
dgl@dgl:~/ > python
Python 2.5.4 (r254:67916, Jul 7 2009, 23:51:24)
...
0
在你看到的内容中,苹果在Snow Leopard 10.6系统中提供了两个版本的Python:一个是默认的Python 2.6.2(位于/usr/bin/python
),另一个是旧版的Python 2.5.4(位于/usr/bin/python2.5
)。这两个版本的核心文件都在/System/Library/Frameworks/Python.framework
这个地方。一般来说,/System
目录下的所有东西都是苹果提供和管理的,其他人不应该去修改。
如果这个信息是对的,那说明你的10.6系统安装有问题。
$ cd /System/Library/Frameworks/Python.framework/Versions
$ ls -l
total 8
drwxr-xr-x 5 root wheel 272 Sep 5 10:18 2.3/
drwxr-xr-x 9 root wheel 408 Sep 5 10:43 2.5/
drwxr-xr-x 9 root wheel 408 Sep 5 10:43 2.6/
lrwxr-xr-x 1 root wheel 3 Sep 5 10:18 Current@ -> 2.6
$ ls -l 2.5/lib/python2.5/distutils/__init__.py
-rw-r--r-- 1 root wheel 635 Jul 7 23:55 2.5/lib/python2.5/distutils/__init__.py
$ /usr/bin/python2.5
Python 2.5.4 (r254:67916, Jul 7 2009, 23:51:24)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils
>>>
你需要检查一下这个文件是否存在,并且权限设置是否正确。如果没有,你就要找找/System
目录下还有什么其他问题,考虑从备份中恢复,或者干脆重新安装Snow Leopard。