Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC-4.2 error on Mac OS-X Mountain Lion, unable to install some packages with pip / virtualenv

I'm seeing a very annoying bug that I don't really know how to deal with. It seems to be pretty common, and I've tried nearly every solution that I could find to no avail.

I'm trying to install libraries using pip. This problem was encountered with gevent, with psycopg2, and with greenlet. The issue seems to be that my computer can't find a particular C compiler that should come up with XCode 4: gcc-4.2. Here's an example (though attempts were made in a virtualenv as well).

Last login: Sun Jul 29 23:35:54 on ttys000
*******s-MacBook-Pro:~ ******$ pip install gevent
Downloading/unpacking gevent
  Downloading gevent-0.13.7.tar.gz (288Kb): 288Kb downloaded
  Running setup.py egg_info for package gevent

Downloading/unpacking greenlet (from gevent)
  Downloading greenlet-0.4.0.zip (72Kb): 72Kb downloaded
  Running setup.py egg_info for package greenlet

Installing collected packages: gevent, greenlet
  Running setup.py install for gevent
    building 'gevent.core' extension
    gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c gevent/core.c -o build/temp.macosx-10.6-intel-2.7/gevent/core.o
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/unicodeobject.h:4,
                 from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:85,
                 from gevent/core.c:4:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from gevent/core.c:225:
gevent/libevent.h:9:19: error: event.h: No such file or directory
gevent/libevent.h:38:20: error: evhttp.h: No such file or directory
gevent/libevent.h:39:19: error: evdns.h: No such file or directory
gevent/core.c:361: error: field ‘ev’ has incomplete type
gevent/core.c:741: warning: parameter names (without types) in function declaration

....more like this but i'll skip it for now....

copying gevent/wsgi.py -> build/lib.macosx-10.6-intel-2.7/gevent

running build_ext

building 'gevent.core' extension

creating build/temp.macosx-10.6-intel-2.7

creating build/temp.macosx-10.6-intel-2.7/gevent

gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c    gevent/core.c -o build/temp.macosx-10.6-intel-2.7/gevent/core.o

In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/unicodeobject.h:4,

             from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:85,

             from gevent/core.c:4:

/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory

In file included from gevent/core.c:225:

gevent/libevent.h:9:19: error: event.h: No such file or directory

gevent/libevent.h:38:20: error: evhttp.h: No such file or directory

gevent/libevent.h:39:19: error: evdns.h: No such file or directory

....more like this as well....

gevent/core.c:15559: warning: assignment makes pointer from integer without a cast

gevent/core.c: At top level:

gevent/core.c:21272: error: expected ‘)’ before ‘val’

lipo: can't figure out the architecture type of:    /var/folders/xc/f2mg5kn96kqdr3tj19pgyhs00000gn/T//cckLxkJ2.out

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

Command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c        "import setuptools;__file__='/Users/******/build/gevent/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record   /var/folders/xc/f2mg5kn96kqdr3tj19pgyhs00000gn/T/pip-yA5oWR-record/install-record.txt failed with error code 1 in /Users/******/build/gevent
Storing complete log in /Users/******/.pip/pip.log
***********s-MacBook-Pro:~ ******$ 

Things you might ask:

1) Did you try using a virtualenv?

Yes. And I attempted to symlink a preexisting gcc (which is present in the /usr/bin/ directory) like so:

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

None of which worked.

2) Did you try reinstalling XCode?

Yes.

3) Did you install the XCode Command Line Tools?

Yes.

4) Are you sure you have gcc?

**********s-MacBook-Pro:~ sanjay$ gcc
i686-apple-darwin11-llvm-gcc-4.2: no input files

5) Python installation?

************s-MacBook-Pro:~ ******$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

Any ideas on what might be wrong and how to fix it?

I also tried installing this: https://github.com/kennethreitz/osx-gcc-installer . I have no idea what else to try. I'm a bit of a new kid on the block when it comes to this unix-y coding / installation things, so if there is something I'm doing very badly please point it out.

Thanks!

like image 646
Johnny W Avatar asked Jul 30 '12 06:07

Johnny W


3 Answers

Same problem with pycrypto install failing to compile in a virtualenv. Found the solution in this thread by poster jiaaro: https://gist.github.com/3179227#gistcomment-379913

You need to install Xcode 4.4 (from the app store) and then, within xcode open Xcode > Preferences (or press Cmd + ,) then open the downloads tab and install the Command Line Tools.

On Mac OSx Mountain Lion 10.8 I had xCode 4.3 installed WITH the command line tools. I did the update to xCode 4.4 and it still didn't work. Xcode does not automatically download the new command line tools apparently even if you had them installed. As the post from jiaaro states, you have to explicitly download the command line tools again.

Current version of gcc is below and does successfully sudo pip install packages in virtualenv for me with no need to sym link.

gcc

i686-apple-darwin11-llvm-gcc-4.2

like image 199
eschipul Avatar answered Oct 19 '22 03:10

eschipul


Setting this environmental variable did it for me, without the need to mess around with Xcode or it's downloads.

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future
like image 33
James Errico Avatar answered Oct 19 '22 05:10

James Errico


This worked for me when I had a similar problem.

http://www.computersnyou.com/2025/2013/06/install-command-line-tools-in-osx-10-9-mavericks-how-to/

like image 24
ben-pr-p Avatar answered Oct 19 '22 04:10

ben-pr-p