Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been trying to install matplotlib through easy_install(easy_install-2.7 for python2.7) and by building from source(

But both fail with the error - "error: Setup script exited with error: command 'gcc' failed with exit status 1"

Not sure if it helps, but more of the error messaging here:

Prior to this i had successfully managed to install all other scientific libraries that i needed - numpy, scipy, pandas, sklearn. But am getting stuck with matplotlib.

To facilitate installations of numpy et al, i had installed quite a few other packages. (I dont't even remember which all)

I fear the worst and assume that some of these related package installations might have impacted some default setting on my Terminal.

All other solutions on SE point to having XCode and XCode command tools installed. But i have the latest version of both.

I see that my usr/bin/ has both gcc & gcc-4.2

Python verion being used - Python2.7 OS - Mac Mountain Lion

I have torn off half of my hair trying to get this installed. Please please heeeelp... before i go completely bald.

UPDATE: i have got it working by installing the .dmg (don't ask why i did not try that before - the easiest solution is at times the best solution)

But still want to know the reason for the above errors. I suspect i might encounter this menace on future installations.

share|improve this question

migrated from Nov 2 '12 at 17:23

This question came from our site for professional and enthusiast programmers.

It looks like a missing header file. But it also looks like you haven't included all of your error message in the paste bin. I would've thought there's more at the top, which may indicate which header file it is having problems finding (I suspect the Python.h one; which requires setting an include path correctly). – Evert Oct 30 '12 at 17:17
@Evert...Sorry about that. Didn't paste the whole messaging. I retried installing using a virtualenv. The error persists. The whole messaging can be found here: .Edited the question too. – Raju Joseph Oct 31 '12 at 4:46
How did you install numpy? Looks like a diy install, and the best I can see are incompatibilities with the numpy installation. numpy is already installed on OSX, so if it all possible, use that one. In fact, your current numpy says "...py2.7-macosx-10.5-intel.egg/..."; that's not Mountain Lion. – Evert Oct 31 '12 at 7:24
Thanks @Evert . I didn't even know that OSX shipped with it's own version of numpy. I installed numpy myself. (easy_install if memory serves me right). On my Python 'numpy.__version__' throws up ''. How do i revert to the OSX version? – Raju Joseph Oct 31 '12 at 11:22
If it's still relevant: find out where that numpy is installed, then just remove or rename out. Find out from the Python prompt with numpy.__file__, then rename or remove that directory. Then try again importing numpy. – Evert Nov 2 '12 at 13:26

Your errors seem related to treetype and/or numpy from OS X. If you have trouble with the (older) numpy shipped by OS X, you may want to give my homebrew-python tap a try. Then, install matplotlib with pip like so (you need Homebrew:

brew install python         # avoid the need for sudo pip
brew install freetype
brew install libpng
brew tap samueljohn/python  # adding numpy, scipy and pillow (PIL) formulae
brew install numpy
pip install matplotlib

If you use the brewed python like shown here, it will be built with clang (yay!) and distutils will also make use of clang if you later build things with pip.

share|improve this answer

Install homebrew then try:

brew install freetype
brew link freetype
brew install libpng
brew link libpng
pip install matplotlib
share|improve this answer
No luck with that either :( Already had freetype & libpng installed and linked. On doing "brew install matplotlib" within my virtualenv it throws: Error: No available formula for matplotlib – Raju Joseph Oct 31 '12 at 4:51
Which is why it says pip install matplotlib and not brew install matplotlib :) – FrenchKheldar Oct 31 '12 at 23:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.