【发布时间】:2013-03-03 10:16:24
【问题描述】:
我正在尝试在 virtualenv 中使用 Scrapy,这也需要安装 twisted。我做了pip install Scrapy 没有问题,但是当我尝试pip install twisted 时,我在输出中多次收到以下错误:
unable to execute gcc-4.0: No such file or directory
error: command 'gcc-4.0' failed with exit status 1
我之前尝试在我的实际系统上安装 python 包时遇到了类似的问题,这就是我首先开始使用 virtualenv 的原因。这是我的环境中安装的 python 版本的问题吗?这是我目前拥有的:
Django - 1.5 - active
Python - 2.7.3 - active development (/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload)
Scrapy - 0.16.4 - active
pip - 1.2.1 - active
setuptools - 0.6c11 - active
wsgiref - 0.1.2 - active development (/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7)
yolk - 0.4.3 - active
为了检查我使用了哪个版本的 gcc,我在命令行输入了 gcc 并得到了
i686-apple-darwin11-llvm-gcc-4.2: no input files
我在运行pip install twisted 之前尝试了export CC=gcc-4.2,得到了:
llvm-gcc-4.2: error trying to exec '/usr/bin/../llvm-gcc-4.2/bin/powerpc-apple-darwin11-llvm-gcc-4.2': execvp: No such file or directory
lipo: can't figure out the architecture type of: /var/folders/s8/d0f65gc93nbchdk52g2cg5f80000gn/T//ccWQa7cJ.out
error: command 'gcc-4.2' failed with exit status 255
在我看来,它好像在寻找 powerpc-apple-darwin11-llvm-gcc-4.2,而我上面的内容是 i686-apple-darwin11-llvm-gcc-4.2——它们是不同的,因此会导致问题吗?
为了提供更多背景信息,我很久以前从 Python.org 安装程序安装了 Python 2.7,然后从 Snow Leopard 直接升级到 Mountain Lion。如果我只是在命令行输入python,我会得到
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:32:06)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
所以我猜这意味着我正在使用 Apple 的 Python?它是用 gcc-4.0.1 构建的?所以如果是这样的话,我不应该不需要做export CC=gcc-4.2吗?还是我需要这样做并切换到 Python.org 版本的 Python? (如果是后者,我该怎么做?)
更新:我尝试this solution 切换 Python 版本,但没有成功。
更新:我设法使用 sudo port select --set python python27 命令切换 Python 版本(在我的 virtualenv 之外),但这并没有解决问题,即使我现在正在显示:
Python 2.7.3 (default, Nov 17 2012, 19:54:34)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
当我在命令行输入python 时。
更新:我还发现this solution 的问题似乎与我遇到的问题几乎完全相同,但我已经升级到 XCode 4.6 并且肯定有命令按照上述解决方案中的说明安装 Line Tools(Preferences>Downloads tab>Install Command Line Tools)。但是,我也安装了 XCode 3.2.6——有没有可能导致我的问题?
【问题讨论】:
-
你可以试试这篇文章中给出的建议,看看问题是否仍然存在? stackoverflow.com/questions/5944228/…
-
@NilanjanBasu,关于我尝试过的事情,请参阅上面编辑过的问题。
标签: twisted virtualenv pip