Mac上的easy_install坏了
我把我的家目录从一台Mac OSX 10.5的电脑复制到了另一台Mac OSX 10.6的电脑上。这导致我在使用二进制包时出现了问题,比如当我用Python 2.5的时候:
> easy_install celery
Searching for celery
Reading http://pypi.python.org/simple/celery/
Reading http://github.com/ask/celery/
Reading http://celeryproject.org
Best match: celery 2.2.7
Downloading http://pypi.python.org/packages/source/c/celery/celery-2.2.7.tar.gz#md5=5826cf891eaa6175cc7aab67818094fe
Processing celery-2.2.7.tar.gz
Running celery-2.2.7/setup.py -q bdist_egg --dist-dir /var/folders/TK/TKwwrl0JEyKrCVteN9D+Jk+++TI/-Tmp-/easy_install-RSjVZt/celery-2.2.7/egg-dist-tmp-w4bMT_
...
In file included from Modules/_multiprocessing/multiprocessing.h:6,
from Modules/_multiprocessing/multiprocessing.c:9:
/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:18:20: error: limits.h: No such file or directory
...
... millions of errors
...
error: Setup script exited with error: command 'gcc' failed with exit status 1
如果我用Python 2.6的话:
> easy_install-2.6 celery
Searching for celery
Reading http://pypi.python.org/simple/celery/
Reading http://github.com/ask/celery/
Reading http://celeryproject.org
Best match: celery 2.2.7
Downloading http://pypi.python.org/packages/source/c/celery/celery-2.2.7.tar.gz#md5=5826cf891eaa6175cc7aab67818094fe
Processing celery-2.2.7.tar.gz
Running celery-2.2.7/setup.py -q bdist_egg --dist-dir /var/folders/TK/TKwwrl0JEyKrCVteN9D+Jk+++TI/-Tmp-/easy_install-dCVly4/celery-2.2.7/egg-dist-tmp-PqOUyI
error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: /var/folders/TK/TKwwrl0JEyKrCVteN9D+Jk+++TI/-Tmp-/easy_install-dCVly4/celery-2.2.7/temp/easy_install-61UKvH/PasteDeploy-1.5.0/temp/easy_install-ExR4d0/Paste-1.7.5.1/temp/easy_install-OJw80Y/PasteDeploy-1.5.0/temp/easy_install-Zg0wGJ/Paste-1.7.5.1/temp/easy_install-aWn8hm/PasteDeploy-1.5.0/temp/easy_install-1TOXq2/Paste-1.7.5.1/temp/easy_install-r97tJG/PasteDeploy-1.5.0/temp/easy_install-CNdClq/Paste-1.7.5.1/temp/easy_install-XUejp4/PasteDeploy-1.5.0/temp/easy_install-xN6Jd6/Paste-1.7.5.1/temp/easy_install-zFbJOI/PasteDeploy-1.5.0/temp/easy_install-fc2q_2/Paste-1.7.5.1/temp/easy_install-1rTVrG/PasteDeploy-1.5.0/temp/easy_install-rii66v/Paste-1.7.5.1/temp/easy_install-cZBf5J/PasteDeploy-1.5.0/temp/easy_install-ICPv8M/Paste-1.7.5.1/temp/easy_install-RwRQIz/PasteDeploy-1.5.0/temp/easy_install-x74lHT/Paste-1.7.5.1/temp/easy_install-Yf8l74/PasteDeploy-1.5.0/temp/easy_install-fnl5Wt/Paste-1.7.5.1/temp/easy_install-OwWNt9/PasteDeploy-1.5.0/temp/easy_install-WkOs3d/Paste-1.7.5.1/docs/include/reference_header.txt: File name too long
这个问题并不是特定于celery的。我在使用lxml、matplotlib、scipy等库时也遇到了类似的错误。这个问题出现在所有的二进制包上,而不是纯Python包上。我到底哪里做错了呢?
> which easy_install
/Library/Frameworks/Python.framework/Versions/Current/bin/easy_install
> which easy_install-2.6
/usr/bin/easy_install-2.6
2 个回答
你安装过XCode吗?看起来你还没有安装。
根据你提供的简短错误信息,很难确定具体问题。一个可能的原因是你在 Mac OS X 10.5 上安装的独立 Python 2.5(很可能是用 python.org 的安装程序安装的)没有被复制过来。如果是这样,你需要在那台机器上安装一个类似的 Python 2.5,或者把 /Library/Frameworks/Python.frameworks
从旧的安装中移动过来。或者,你可以考虑更新到一个较新的 Python 版本,可以是系统自带的,或者是从 python.org、MacPorts、homebrew、Fink 或 ActiveState 等第三方开源分发商那里获取的。
另一个可能性是你需要从 Xcode 3 的安装程序中安装可选的 MacOSX 10.4u SDK
,适用于 Mac OS X 10.6。如果是这种情况,你应该会看到包含 10.3
或 10.4
的错误信息。
更新一下:看起来你确实安装了一个 easy_install
,可能是针对额外的 python.org 版本,或者是指向 /Library/Frameworks/Python.framework/Versions/Current
的 Python 版本。你似乎遇到了两个不同的问题(一个是 Python 2.5,另一个是系统自带的 Python 2.6)。在这个时候,没有更多的信息,我很难猜测这两个问题是什么。可能最好的办法是清理一下,然后重新开始。
如果你想删除从旧系统带过来的旧 Python 2.5,可以按照 这里 的说明来删除 python.org 安装的 Python。如果你愿意,可以先备份一下,或者把它重命名,比如:
cd /Library/Frameworks/Python.framework/Versions sudo mv 2.5 2.5-OLD
对于其他的 Python 版本也可以考虑这样做。千万不要删除或修改
/System/Library/Frameworks
或/usr/bin
里的任何文件。这些目录是 OS X 的一部分。确保清理你的 shell 配置文件,比如
.bash_profile
等,确保你的 PATH 中不再包含这个 Python。确保没有意外的PYTHONPATH
环境变量。确保你的主目录中没有过时的 Distutils 配置文件。查找并重命名或删除像
.pydistutils.cfg
这样的文件。cd ~ ls -al
同时确保没有意外的私有包安装在本地目录中。
ls -al ~/Library/Python ls -al ~/.local
检查并在必要时删除 Apple 提供的 Python 的
site-packages
目录中的任何内容:cd /Library/Python/2.6/site-packages ls -al cd /Library/Python/2.5/site-packages ls -al
开启一个新的终端会话,确认一切正常。
决定你想在 10.6 上使用哪个版本的 Python。如果你愿意使用 Apple 提供的 2.6.1 或 2.5.4 版本,那就用它们吧。这两个版本都自带了自己的
easy_install
,在/usr/bin
中。$ ls -l /usr/bin/python* -rwxr-xr-x 2 root wheel 86000 Jun 24 2010 /usr/bin/python* -rwxr-xr-x 5 root wheel 925 Jul 7 2009 /usr/bin/python-config* lrwxr-xr-x 1 root wheel 75 Nov 7 2010 /usr/bin/python2.5@ -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 lrwxr-xr-x 1 root wheel 82 Nov 7 2010 /usr/bin/python2.5-config@ -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5-config lrwxr-xr-x 1 root wheel 75 Nov 7 2010 /usr/bin/python2.6@ -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 lrwxr-xr-x 1 root wheel 82 Nov 7 2010 /usr/bin/python2.6-config@ -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config -rwxr-xr-x 2 root wheel 86000 Jun 24 2010 /usr/bin/pythonw* lrwxr-xr-x 1 root wheel 76 Nov 7 2010 /usr/bin/pythonw2.5@ -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw2.5 lrwxr-xr-x 1 root wheel 76 Nov 7 2010 /usr/bin/pythonw2.6@ -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6 $ ls -l /usr/bin/easy* -rwxr-xr-x 2 root wheel 925 Jun 30 2009 /usr/bin/easy_install* -rwxr-xr-x 1 root wheel 421 Jun 30 2009 /usr/bin/easy_install-2.5* -rwxr-xr-x 1 root wheel 421 Jun 30 2009 /usr/bin/easy_install-2.6*
如果你想要更新的 Python 版本,可以考虑从 python.org 或者 homebrew、MacPorts、Fink、ActiveState 等地方安装最新的 Python(当前 Python 2 的版本是 2.7.2)。根据需要更新你的 shell PATH。(例如,python.org 的安装程序默认会适当地修改你的 shell 配置文件。)
如果安装包中没有自带
easy_install
(python.org 的没有,其他一些可能有可选的包),可以安装 Distribute 包,这样就会提供一个easy_install
。