Recently started a new project and ran into this error while installing pycrypto. Every single post seems to just say: install command line tools with the latest version of Xcode and your problems will magically go away!

Well, if that works for you, great, if not, let’s get down to the root of the matter.

(greedychimp)nai@nyc:~/Work/greedychimp(develop○) » python                           18 ↵
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

For some reason, my virtualenv was using Apple’s version Python which was compiled with llvm-gcc. We don’t want that, we want the clang compiled version of Python to get this to work.

(greedychimp)nai@nyc:~/Work/greedychimp(develop○) » port select --list python         1 ↵
Available versions for python:
	none (active)
	python25-apple
	python26-apple
	python27
	python27-apple

Seems like I had the clang compiled version of python already but hadn’t set it as default.

(greedychimp)nai@nyc:~/Work/greedychimp(develop○) » sudo port select --set python python27
Password:
Selecting 'python27' for 'python' succeeded. 'python27' is now active.
nai@nyc:~ » port select --list python
Available versions for python:
	none
	python25-apple
	python26-apple
	python27 (active)
	python27-apple

Great, now when I type Python in my terminal outside my virtualenv, I should see a clang compiled version of python which I do.

nai@nyc:~ » python
Python 2.7.3 (default, Oct 22 2012, 06:12:32) 
[GCC 4.2.1 Compatible Apple Clang 3.1 (tags/Apple/clang-318.0.58)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

However, my virtualenvs are still using the old version of Python. So I have to recreate the virtualenv and specifically tell virtualenv which Python to use.

nai@nyc:~ » mkvirtualenv --python=/opt/local/bin/python2.7 greedychimp
Running virtualenv with interpreter /opt/local/bin/python2.7
New python executable in greedychimp/bin/python
Installing setuptools............done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /Users/nai/.virtualenvs/greedychimp/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/nai/.virtualenvs/greedychimp/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/nai/.virtualenvs/greedychimp/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/nai/.virtualenvs/greedychimp/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/nai/.virtualenvs/greedychimp/bin/get_env_details
[8] 37201
/Users/nai/.virtualenvs/postactivate:disown:15: warning: job is suspended, use `kill -CONT -36852' to resume
[8]  - 37201 done       ctags -f $VIRTUAL_ENV/tags -R $VIRTUAL_ENV/lib/python2.7/site-packages ${PWD}
(greedychimp)nai@nyc:~/Work/greedychimp(develop⚡) » python
Python 2.7.3 (default, Oct 22 2012, 06:12:32) 
[GCC 4.2.1 Compatible Apple Clang 3.1 (tags/Apple/clang-318.0.58)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

So running pip install pycrypto should work now.

Advertisements

2 thoughts on “error: command ‘llvm-gcc-4.2’ failed with exit status 1

  1. Pingback: How To Fix Error Command ‘gcc’ Failed With Exit Status 1 in Windows

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s