在虚拟环境中扭曲的pip安装中缺少gcc-4.0错误

时间:2013-03-03 10:16:24

标签: twisted virtualenv pip

我正在尝试在virtualenv中使用Scrapy,这也需要安装扭曲。我没有问题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

我在运行export CC=gcc-4.2之前尝试了pip install twisted,我得到了:

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的Python.org版本? (如果是后者,我该怎么做?)

更新:我尝试this solution来切换Python版本,但它没有用。

更新:我设法使用sudo port select --set python python27命令切换Python版本(在我的virtualenv之外),但即使我现在显示,这也没有解决问题:< / p>

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并且肯定有如上述解决方案(首选项&gt;下载选项卡&gt;安装命令行工具)中所述安装的命令行工具。我也安装了XCode 3.2.6,但是 - 这会导致我的问题吗?

1 个答案:

答案 0 :(得分:1)

你试过CC="$(type -p clang)" pip install twisted吗?您不一定需要使用gcc来编译Twisted的扩展;选择clang可能会清除任何奇怪的问题似乎正在侵扰您的gcc安装。

如果这不起作用,我建议不要安装Python的任何Python.org版本,然后可能重新安装操作系统和Xcode,因为它看起来可能已经损坏了系统的Python安装。由于Lion删除了对ppc的支持,因此我不知道对Mountain Lion的引用是如何持续存在的。{/ p>