2012-03-12 121 views
2

我想在我的Mac OS X Lion 10.7.3上构建一些库(如寓言,PIL ..)。当我输入的终端Python解释器,我的GCC 4.0.1版本:Python和GCC版本

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 14:13:39) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin 

但有趣的是,如果我进入python2.6,我有GCC 4.2.1:

[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin 
Type "help", "copyright", "credits" or "license" for more information.` 

我想要使用Python(版本2.7.2,因为它是我拥有的最新版本),但在这个Python版本中编译是不可能的。用命令python setup.py install,我有错误消息:

unable to execute gcc-4.0: No such file or directory 
error: command 'gcc-4.0' failed with exit status 1 

是正常在Mac上?任何人都可以帮我定义gcc 4.2.1Python 2.7.2

+0

没有必要使用与Python相同的编译器版本来编译PIL。我不知道如何告诉setuptools使用哪个编译器版本。我的第一个猜测是'export CC = gcc'。 – 2012-03-12 18:41:11

+1

您的python 2.7.2二进制文件是使用GCC 4.0.1编译的。你的python 2.6是使用GCC 4.2.1编译的。这并不意味着你实际上已经安装了这些GCC版本。 – sepp2k 2012-03-12 18:41:19

+1

[This](http://stackoverflow.com/questions/3500638/reinstalling-python-on-mac-os-10-6-with-a-different-gcc-version)可能会有所帮助... – CoffeeRain 2012-03-12 19:26:15

回答

1

在sudo su模式下输入此命令export ARCHFLAGS="-arch i686"即可解决问题。不要问我为什么!