Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac osx lion, virtualenv, pil install - gcc error

I have just completed the xcode install, mac osx lion. Upon completion I attempted to install PIL in a virtual enviroment using pip, easy_install and home brew. All three are erring out. pip install give the following error:

pip `

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

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

`

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

home brew Error: Failed executing: python setup.py build_ext

I am not really sure where to go from here.

Thanks, CG

like image 583
Cory Gwin Avatar asked Aug 02 '11 01:08

Cory Gwin


People also ask

Can we install GCC in Mac?

Go to "Apple menu > About This Mac" if unsure): Installing MacPorts. Open a Terminal window and enter "sudo port -v selfupdate". Enter your password, and wait for the update to finish. Once it finishes, enter "sudo port install gcc5".

Is GCC pre installed on Mac?

The gcc application will be installed by default in /usr/local/bin. Personally, I use Apple's clang/clang++ compilation tools rather than deal with GNU gcc. If you have the most recent Apple Command Line Tools (macOS 10.


2 Answers

Xcode 4.1 on OS X Lion 10.7 no longer includes gcc-4.0 as it did in earlier versions of OS X. When you install a Python package like PIL that includes a C extension module, Python's Distutils will attempt to use the same version of the C compiler that that Python itself was build with. It sounds like the version of Python that was used to create your virtualenv is an older 32-bit-only Python built with gcc-4.0. You can tell for sure by starting the python in your virtualenv. If it says gcc-4.0, you will need to re-create the virtualenv, using a newer base Python, either one of the Apple-supplied Pythons in Lion or installing a newer python using a python.org installer or a brew recipe. Then install Distribute and pip and virtualenv for that Python, create a new virutalenv and then install PIL in it.

like image 101
Ned Deily Avatar answered Nov 03 '22 01:11

Ned Deily


After spending hours on the same problem this is what it worked for me:

Download the PIL source code and cd into it. Check which version of gcc do you have by:

gcc
i686-apple-darwin10-gcc-4.2.1: no input files

Then I force to apply this version by:

export CC=gcc-4.2

And select the correct architecture (in my case 32bit):

export ARCHFLAGS="-arch i386"

For 64 use export ARCHFLAGS="-arch x86_64"

Then build and install:

python setup.py build
python setup.py install
like image 1
Josep Virgili Llop Avatar answered Nov 02 '22 23:11

Josep Virgili Llop