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:

  1. Download and install the Python 2.7 DMG.
  2. Download and install  Numpy 1.6.0b1. *Yes, it’s the 2.6 one. :/ It works, though.
  3. Download and expand Matplotlib 1.0.1 source package.
  4. In the root source directory
    cp setup.cfg.template setup.cfg
  5. Edit setup.cfg, uncomment line 10, and make it read:
    basedirlist = /usr/X11
  6. 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
  7. Have a beer in celebration.

(keywords: Matplotlib 64-bit Mac OS X Leopard Python 2.7 freetype2)

About these ads

~ by voidptr on March 29, 2011.

19 Responses to “Compiling Matplotlib 1.0.1 on 64-bit Mac OS X Leopard for Python 2.7”

  1. 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.

  2. 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

  3. Thanks Ivan, yes removing [-2] from line 832 did the trick!

  4. 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

  5. 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

  6. 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)

  7. 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

  8. 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)

  9. 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.

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

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: