2013-02-06 314 views
0

目前,由于gcc-4.0错误,我无法安装任何Python软件包。我会复制我得到了错误的两个例子(一个PIP,对方用手动setup.py构建/安装方法):OSX:安装python软件包时出错

sgarza62$ pip install PIL 
Downloading/unpacking PIL 
    Running setup.py egg_info for package PIL 
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py 

Installing collected packages: PIL 
    Running setup.py install for PIL 
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py 
    --- using frameworks at /System/Library/Frameworks 
    building '_imaging' extension 
    gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -arch ppc -arch i386 -g -O2 -DNDEBUG -g -O3 -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.3-fat-2.7/_imaging.o 
    unable to execute gcc-4.0: No such file or directory 
    error: command 'gcc-4.0' failed with exit status 1 
    Complete output from command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools;__file__='/var/folders/9q/bvqtzkbx1hg1934b36zgk0y40000gp/T/pip-build/PIL/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/9q/bvqtzkbx1hg1934b36zgk0y40000gp/T/pip-nV9YEx-record/install-record.txt --single-version-externally-managed: 
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py 

running install 

running build 

running build_py 

running build_ext 

--- using frameworks at /System/Library/Frameworks 

building '_imaging' extension 

gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -arch ppc -arch i386 -g -O2 -DNDEBUG -g -O3 -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.3-fat-2.7/_imaging.o 

unable to execute gcc-4.0: No such file or directory 

error: command 'gcc-4.0' failed with exit status 1 

sgarza62$ cd Imaging-1.1.7 
sgarza62$ sudo python setup.py build 
running build 
running build_py 
running build_ext 
--- using frameworks at /System/Library/Frameworks 
building '_imaging' extension 
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -arch ppc -arch i386 -g -O2 -DNDEBUG -g -O3 -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.3-fat-2.7/_imaging.o 
unable to execute gcc-4.0: No such file or directory 
error: command 'gcc-4.0' failed with exit status 1 

这里有一堆信息,我会从终端复制,希望其中的一些有助于确定问题:

sgarza62$ gcc 
i686-apple-darwin11-llvm-gcc-4.2: no input files 

sgarza62$ 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 
Type "help", "copyright", "credits" or "license" for more information. 
>>> 

sgarza62$ which python 
/Library/Frameworks/Python.framework/Versions/2.7/bin/python 

sgarza62$ echo $PATH 
/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin 

sgarza62$ /usr/bin/python -c 'import sys;print(sys.version)' 
2.7.2 (default, Jun 16 2012, 12:38:40) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] 
sgarza62$ /usr/bin/python2.6 -c 'import sys; print(sys.version)' 
2.6.7 (r267:88850, Jun 16 2012, 12:38:45) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] 
sgarza62$ /usr/bin/python2.5 -c 'import sys;print(sys.version)' 
2.5.6 (r256:88840, Jun 16 2012, 12:38:24) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] 
sgarza62$ /usr/bin/python2.7 -c 'import sys;print(sys.version)' 
2.7.2 (default, Jun 16 2012, 12:38:40) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] 

这里有一些问题/一个在堆栈上解决相同或类似问题(但没有提供我的问题的完整解决方案)的nswers。也许这些以前的答案将是使用搞清楚这个问题:

Reinstalling python on Mac OS 10.6 with a different gcc version

How to use/install gcc on Mac OS X 10.8/Xcode 4.4

Python build using wrong version of GCC on OS X


这是我已经做过的事情,这已经建议堆栈用户出现类似问题:

  • 下载Xcode的

  • 安装命令行工具在Xcode的喜好

  • sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2


我已经做了我的问题,最好给尽可能多的事实,尽可能以清晰有序的方式。但是,如果你们需要更多信息,请询问!我会很乐意编辑更多细节的问题。

此外,我知道这似乎是一个非常具体的问题,但从四处搜寻,看起来像很多人都对这个问题感到困惑。

如果你不介意的话,我会非常感谢一个勺子喂食的解决方案(明确说明我在终端中必须做什么来解决这个问题)。我在终端上还不是很舒服,并且对一般化的答案有些困惑。

谢谢大家的时间,我欣赏它!

回答

4

这里的问题是,你正试图在Xcode 4的OS X系统上使用仅32位的python.org 2.7.3。仅32位的安装程序被设计为跨数字兼容的OS X发布回到10.3.9。不幸的是,随着Xcode 4中PPC支持的删除以及其他各种更改的出现,安装具有C扩展模块的第三方Python软件包在10.7及更高版本的Xcode 4系统上不再适用。尽管如此,仍有可能解决它们。在PIL的情况下,通过环境变量改变了一些Python的Distutils默认的应该做的伎俩:

# override the default gcc-4.0 compiler and use clang instead 
$ export CC=clang 
# override the universal architectures to only use Intel-32 
$ export ARCHFLAGS='-arch i386' 
$ pip install PIL 

的python.org网站为当前的Python释放两个OS X安装程序的变种。另一个安装程序64位/ 32位版本提供的Python被配置为更小,更新的系统范围;它不支持PPC,并且不会支持Xcode 4.

顺便说一句,Python 2.7的下一个版本(2.7.4)提供了更好的支持Xcode 4的安装程序,不应该有这个问题。

+0

Ned,您似乎是与gcc,Python,Xcode和Python包相关的问题的权威人士。你介意看看这个问题,让我知道你是否可以帮忙?我一直坚持这个问题好几天,没有其他人的解决方案为我工作:http://stackoverflow.com/q/15795757/1337422 – sgarza62