Gcc-4.0 error when creating _volume extension for PIL

When I install PIL (or pad), the _imaging C module is not installed.

This is a common mistake, and we saw the AppeL play-by-play solution , which most of them found useful. Unfortunately, when I run sudo python setup.py install , I get the following error:

 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 

When I run python in a shell and try to import modules, I get the following import errors:

 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 

I had similar errors earlier , and Ned Deily was kind enough to provide solutions . I believe that my current problem may be related to this previous question:

OSX: error installing Python packages (including this link)

Here is another potentially useful information:

 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 

I am not very familiar with inserts if gcc, Xcode or PIL. So, if you do not mind, provide detailed answers so that I understand how to act on your decision. Also, let me know if I can provide more details, and I will edit them in the question.


EDIT:

I installed a pillow with pip, as suggested by MattDMo , Image now successfully imported, but _imaging not (I believe c extensions will not compile gcc properly on my machine, see above):

 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 

I use PIL for image processing in a Django web application, and I get the following error when trying to upload an image through a processing form using PIL:

 The _imaging C module is not installed 

SECOND EDIT:

Here's more info related to python and gcc, which I hope will shed light on the problem:

 $ 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)] 
0
source share
2 answers

Wow. Hope this helps people who have the same problem in the future because it was cruel.

The solution was to install the python.org 64-bit/32-bit installer for Mac, as stated in Ned Deily , to the question "... cannot determine the type of architecture ..." when compiling the Python C-extension with gcc .

Firstly, I made sure python was this new python by default (just by running python in the shell).

Then I reinstalled pip and ran pip install PIL . And it's all!

Just to make sure, I opened python in the shell and imported three modules:

 >>> import PIL >>> import Image >>> import _imaging 

All of them (finally) were imported without errors.

0
source

Many, if not all of your problems (hopefully) can be solved with Pillow . PIL development was simply stopped some time ago, and, unfortunately, the code was not compatible with Perwards, as compilers and Python matured, errors appeared. The Pillow fork is stable, actively developed and fairly widespread, so you can feel safe. Version 2.0 contains many improvements, including support for Python 3. However, you will have to use from PIL import Image instead of import Image . Good luck

+2
source

All Articles