Compiling Matplotlib 1.0.1 on 64-bit Mac OS X Leopard for Python 2.7
(…when you don’t already have freetype installed in a sane location as might happen with a different version of X, or sometimes if you’ve got a fancy version of LaTeX)
What a huge pain in the ass to figure this out.
Anyway:
- Download and install the Python 2.7 DMG.
- Download and install Numpy 1.6.0b1. *Yes, it’s the 2.6 one. :/ It works, though.
- Download and expand Matplotlib 1.0.1 source package.
- In the root source directory
cp setup.cfg.template setup.cfg
- Edit setup.cfg, uncomment line 10, and make it read:
basedirlist = /usr/X11
- In the root source directory, run:
python2.7 setup.py build**You want to do install, not build. Thx Ivan. python2.7 setup.py install - Have a beer in celebration.
(keywords: Matplotlib 64-bit Mac OS X Leopard Python 2.7 freetype2)

RSS
Very nice. I encounter this problem today. Really messy.
The last step should be
python setup.py install
To actually install the stuff to its location.
Good catch. Fixed.
I had an additional problem. python.org 2.7.2(?) dmg and matplotlib 1.0.1
The setup.py install step crashed out because the installer was expecting Tkinter.__version__ to return something meaningful, instead it was $Revision$. Had to hack that line to remove the array indices and then all was fine
Interesting. Post a diff here if you think of it.
Thanks Ivan, yes removing [-2] from line 832 did the trick!
I’ll add that to the instructions, thx!
I’m getting a bunch of the following errors:
/usr/X11/include/png.h:666: error: forward declaration of ‘struct png_info_def’
Any clues on how to fix?
Thanks
I’m guessing your X11 libraries are the wrong version. What version of Snow Leopard are you running?
Maybe my problem is I’m using 10.7.1–Lion.
Ah, well, these instructions were for 64 bit snow leopard. It is possible the regular packages would work for you, but I have no way to test. I’m giving Lion a miss. Good luck!
-r
Thank you….SO…HONKING…MUCH!!!!!!!!!!!!!!!!!!! I’ve been going absolutely crazy over this for 24 hours and I do not have the skills to diagnose these issues!
I also had to fiddle with the line of code checking Tkinter.__version__ (per howard456′s comment), and now matplotlib runs fine on my system (os: 10.6.8, python: 2.7.2 64-bit)
Sorry: this doesn’t work. I can get it to install but
import matplotlib still gives me this error
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_path.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_path.so: no matching architecture in universal wrapper
Also found this roadblock:
http://stackoverflow.com/questions/5419439/matplotlib-pyplot-on-os-x-with-64-bit-python-from-python-org
Thank you, there were no mistake importing matplotlib, but when I try to import pyplot from matplot lib, I have the following mistake:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py in ()
245 return manager
246
–> 247 class TimerMac(_macosx.Timer, TimerBase):
248 ”’
249 Subclass of :class:`backend_bases.TimerBase` that uses CoreFoundation
AttributeError: ‘module’ object has no attribute ‘Timer’
what is this Timer??
Can you post your code?
Well I simply imported numpy, scipy and matplotlib, and then I entered:
from matplotlib import pyplot, I also tried import matplotlib.pyplot, but it’s the same error:
(…)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pyplot.py in ()
93
94 from matplotlib.backends import pylab_setup
—> 95 new_figure_manager, draw_if_interactive, _show = pylab_setup()
96
97 @docstring.copy_dedent(Artist.findobj)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/__init__.pyc in pylab_setup()
23 backend_name = ‘matplotlib.backends.%s’%backend_name.lower()
24 backend_mod = __import__(backend_name,
—> 25 globals(),locals(),[backend_name])
26
27 # Things we pull in from all backends
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py in ()
245 return manager
246
–> 247 class TimerMac(_macosx.Timer, TimerBase):
248 ”’
249 Subclass of :class:`backend_bases.TimerBase` that uses CoreFoundation
AttributeError: ‘module’ object has no attribute ‘Timer’
(mac OS X 10.5, in Ipython working with python2.7)
It should work like this:
import matplotlib.pyplot as plt
But, just from looking at your error messages, it doesn’t look like you have a complete python library installation. I would reinstall python. Good luck!
I reinstalled python 2.7, took a look on http://www.mtheory.co.uk/support/index.php?title=Installing_Python_-_iPython%2C_Numpy%2C_Scipy_and_Matplotlib_on_OS_X#Matplotlib
and mixed the whole thing…it works! (I used matplotlib 1.1.0 though, and no need to remove [-2] from line 832 )
thanks a lot!
At the final step–I get this error then exit:
lipo: can’t figure out the architecture type of: /var/folders/26/1mp303md1tj6rc5q_p6p765h0000gn/T//ccZseVt2.out
error: command ‘gcc-4.2′ failed with exit status 1
That means the compilation failed somewhere. You’ll need to find the log with the actual error in it.