当我安装PIL(或枕头)时,不会安装_imaging C模块。构建PIL的_imaging扩展时出现gcc-4.0错误
这是一个常见错误,并且看到ApPeL's play-by-play solution大多数人发现有帮助。不幸的是,当我运行sudo python setup.py install
,我得到以下错误:
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_LIBJPEG -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/local/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
当我运行shell蟒蛇,并尝试导入的模块,我得到这些导入错误:
Santiagos-MacBook-Air:Imaging-1.1.7 sgarza621$ 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.
>>> import PIL
>>> import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Image
>>> import _imaging
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named _imaging
我以前有类似的错误,并且Ned Deily has been kind enough to provide solutions。我相信我现在的问题可能被链接到这个先前的问题:
OSX: error when installing Python packages(包括此作为参考)
下面是一些其他潜在有用的信息:
Santiagos-MacBook-Air:Imaging-1.1.7 sgarza621$ 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.
Santiagos-MacBook-Air:Imaging-1.1.7 sgarza621$ gcc
i686-apple-darwin11-llvm-gcc-4.2: no input files
Santiagos-MacBook-Air:Imaging-1.1.7 sgarza621$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
Santiagos-MacBook-Air:Imaging-1.1.7 sgarza621$ 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
我对gcc,Xcode或PIL不是很熟悉。所以,如果您不介意,请提供详细的回复,以便我了解如何处理您的解决方案。另外,让我知道我是否可以提供更多细节,并将其编辑为问题。
编辑:
我已经安装了pillow
与点子,由MattDMo的建议,现在Image
成功导入,但_imaging
没有(我相信C扩展不由被正确编译GCC我的机器上,见上文):
Santiagos-MacBook-Air:riotry_mobile sgarza621$ 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.
>>> import Image
>>> import _imaging
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_imaging.so, 2): Symbol not found: _jpeg_resync_to_restart
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_imaging.so
Expected in: dynamic lookup
我使用PIL来处理一个Django的web应用程序的图像,我得到以下错误,当我尝试uploa d通过PIL用于处理的形式的图像:
The _imaging C module is not installed
第二个编辑:
这里的更多信息,与蟒蛇和gcc,我希望将阐明这个问题光:
$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
$ /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)]
$ /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)]
很高兴您的工作能够顺利进行。在OS X上安装PIL还有其他可能的缺陷.OS X不附带支持JPEG的库PIL需求;如果你需要的话,你可能还需要编译和安装libjpeg并重建PIL。看来您的原始问题是由Python 2.7.3带有Xcode 4(OS X 10.7或10.8)上的python.org OS X 32位安装程序引起的。如果不进行调整,该组合效果不佳。您发现使用2.7.3的64位/ 32位安装程序效果更好。 (2.7.4即将发布的效果更好)。 – 2013-04-04 03:52:59
但是,因为PIL需要额外的第三方库以提供全部功能,所以我强烈建议您使用OS X的开放源码软件包分销商(MacPorts,Homebrew或Fink)来安装您需要的所有软件,包括Django,Python ,PIL,MySQL或PostgreSQL。从长远来看,您几乎可以肯定的为自己节省大量时间和头痛,因为他们已经想出了如何轻松安装,更新和删除数百个应该一起玩的组件。 – 2013-04-04 03:58:37