Problems installing MPL on OS X 10.6 Snow Leopard with python2.7

Hi all,

I am trying to install matplotlib on a MacMini Intel Core 2 Duo with a clean install of Mac OS X 10.6. I am using python 2.7 that I built from source using the homebrew package installer. I also installed numpy 1.5.1 from source, using the following environment variables:

export MACOSX_DEPLOYMENT_TARGET=10.6

export CFLAGS="-arch i386 -arch x86_64"

export FFLAGS="-m32 -m64"

export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch i386 -arch x86_64 -framework Accelerate"

I also used gfortran 4.2.3 precompiled that I downloaded from http://r.research.att.com/tools/

NOTE: I previously performed this whole install process on a brand new MacBook Air, and it worked without a problem.

I ran numpy.test() and got the following output:

In [4]: numpy.test()

Running unit tests for numpy

NumPy version 1.5.1

NumPy is installed in /usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/numpy

Python version 2.7.1 (r271:86832, Dec 13 2010, 14:21:05) [GCC 4.2.1 (Apple Inc. build 5664)]

nose version 0.11.4

[…snip…]

Ran 3006 tests in 18.696s

OK (KNOWNFAIL=4, SKIP=1)

Out[4]: <nose.result.TextTestResult run=3006 errors=0 failures=0>

Also, when I try to import numpy.core.multiarray, I get no errors.

Finally, I cloned the latest GitHub MPL and set make.osx to be the following (note: changed pyversion, pngfamily, pngversion, deployment target, and the FFLAGS variable):

build mpl into a local install dir with

PREFIX=/Users/jdhunter/dev make -f make.osx fetch deps mpl_install

MPLVERSION=1.0rc1

PYVERSION=2.7

PYTHON=python${PYVERSION}

ZLIBVERSION=1.2.3

PNGFAMILY=12

PNGVERSION=1.2.44

FREETYPEVERSION=2.3.11

MACOSX_DEPLOYMENT_TARGET=10.6

OSX_SDK_VER=10.6

ARCH_FLAGS="-arch i386 -arch x86_64"

You shouldn’t need to configure past this point

PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"

CFLAGS="-arch i386 -arch x86_64 -I${PREFIX}/include -I${PREFIX}/include/freetype2 -isysroot /Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"

LDFLAGS="-arch i386 -arch x86_64 -L${PREFIX}/lib -syslibroot,/Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"

FFLAGS="-arch i386 -arch x86_64"

The install seems to go fine. I can import matplotlib. But when I import matplotlib.pyplot, I get the following:

In [2]: import matplotlib.pyplot

···

RuntimeError Traceback (most recent call last)

RuntimeError: module compiled against ABI version 2000000 but this version of numpy is 1000009


ImportError Traceback (most recent call last)

/Users/laserson/ in ()

/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/pyplot.py in ()

21 from matplotlib.cbook import dedent, silent_list, is_string_like, is_numlike

22 from matplotlib import docstring

—> 23 from matplotlib.figure import Figure, figaspect

24 from matplotlib.backend_bases import FigureCanvasBase

25 from matplotlib.image import imread as _imread

/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/figure.py in ()

14 import numpy as np

15

—> 16 import artist

17 from artist import Artist, allow_rasterization

18 from axes import Axes, SubplotBase, subplot_class_factory

/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/artist.py in ()

4 import matplotlib.cbook as cbook

5 from matplotlib import docstring, rcParams

----> 6 from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath

7 from path import Path

8

/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/transforms.py in ()

32 import numpy as np

33 from numpy import ma

—> 34 from matplotlib._path import affine_transform

35 from numpy.linalg import inv

36

ImportError: numpy.core.multiarray failed to import

It is strange because when I import numpy.core.multiarray, I have no problems. It also raises a RuntimeError, yelling about an ABI incompatibility.

Does anyone know how to solve this problem? I was able to get this to work on another computer…strange that it fails now.

Thanks!

Uri

Uri Laserson
Graduate Student, Biomedical Engineering

Harvard-MIT Division of Health Sciences and Technology

M +1 917 742 8019
laserson@…1166…

Can you try importing pyplot from a regular python prompt? If that
works, then the issue is with ipython messing up the import process of
mpl.

Ben Root

···

On Monday, December 13, 2010, Uri Laserson <laserson@...1166...> wrote:

Hi all,
I am trying to install matplotlib on a MacMini Intel Core 2 Duo with a clean install of Mac OS X 10.6. I am using python 2.7 that I built from source using the homebrew package installer. I also installed numpy 1.5.1 from source, using the following environment variables:

export MACOSX_DEPLOYMENT_TARGET=10.6export CFLAGS="-arch i386 -arch x86_64"

export FFLAGS="-m32 -m64"export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch i386 -arch x86_64 -framework Accelerate"
I also used gfortran 4.2.3 precompiled that I downloaded from Tools - R for Mac OS X - developer's page - GNU Fortan for Xcode

NOTE: I previously performed this whole install process on a brand new MacBook Air, and it worked without a problem.
I ran numpy.test() and got the following output:

In [4]: numpy.test()Running unit tests for numpyNumPy version 1.5.1NumPy is installed in /usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/numpyPython version 2.7.1 (r271:86832, Dec 13 2010, 14:21:05) [GCC 4.2.1 (Apple Inc. build 5664)]

nose version 0.11.4
[...snip...]
Ran 3006 tests in 18.696s
OK (KNOWNFAIL=4, SKIP=1)Out[4]: <nose.result.TextTestResult run=3006 errors=0 failures=0>

Also, when I try to import numpy.core.multiarray, I get no errors.
Finally, I cloned the latest GitHub MPL and set make.osx to be the following (note: changed pyversion, pngfamily, pngversion, deployment target, and the FFLAGS variable):

# build mpl into a local install dir with# PREFIX=/Users/jdhunter/dev make -f make.osx fetch deps mpl_installMPLVERSION=1.0rc1PYVERSION=2.7PYTHON=python${PYVERSION}

ZLIBVERSION=1.2.3PNGFAMILY=12PNGVERSION=1.2.44FREETYPEVERSION=2.3.11MACOSX_DEPLOYMENT_TARGET=10.6OSX_SDK_VER=10.6ARCH_FLAGS="-arch i386 -arch x86_64"

## You shouldn't need to configure past this point
PKG_CONFIG_PATH="\{PREFIX\}/lib/pkgconfig&quot;CFLAGS=&quot;\-arch i386 \-arch x86\_64 \-I{PREFIX}/include -I${PREFIX}/include/freetype2 -isysroot /Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"

LDFLAGS="-arch i386 -arch x86_64 -L${PREFIX}/lib -syslibroot,/Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"FFLAGS="-arch i386 -arch x86_64"
The install seems to go fine. I can import matplotlib. But when I import matplotlib.pyplot, I get the following:

In [2]: import matplotlib.pyplot---------------------------------------------------------------------------RuntimeError Traceback (most recent call last)

RuntimeError: module compiled against ABI version 2000000 but this version of numpy is 1000009---------------------------------------------------------------------------

ImportError Traceback (most recent call last)
/Users/laserson/<ipython console> in <module>()
/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()

 21 from matplotlib\.cbook import dedent, silent\_list, is\_string\_like, is\_numlike     22 from matplotlib import docstring\-\-\-&gt; 23 from matplotlib\.figure import Figure, figaspect
 24 from matplotlib\.backend\_bases import FigureCanvasBase
 25 from matplotlib\.image import imread as \_imread

/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/figure.py in <module>() 14 import numpy as np

 15 \-\-\-&gt; 16 import artist     17 from artist import Artist, allow\_rasterization     18 from axes import Axes, SubplotBase, subplot\_class\_factory

/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/artist.py in <module>()

  4 import matplotlib\.cbook as cbook      5 from matplotlib import docstring, rcParams\-\-\-\-&gt; 6 from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath      7 from path import Path

  8

/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/transforms.py in <module>() 32 import numpy as np 33 from numpy import ma

---> 34 from matplotlib._path import affine_transform 35 from numpy.linalg import inv 36
ImportError: numpy.core.multiarray failed to import

It is strange because when I import numpy.core.multiarray, I have no problems. It also raises a RuntimeError, yelling about an ABI incompatibility.
Does anyone know how to solve this problem? I was able to get this to work on another computer..strange that it fails now.

Thanks!Uri
...................................................................................Uri Laserson
Graduate Student, Biomedical Engineering
Harvard-MIT Division of Health Sciences and Technology
M +1 917 742 8019
laserson@...1166...

Can you try importing pyplot from a regular python prompt? If that

works, then the issue is with ipython messing up the import process of

mpl.

I get exactly the same problem…

laserson@…2710…:~$ python

Python 2.7.1 (r271:86832, Dec 13 2010, 14:21:05)

[GCC 4.2.1 (Apple Inc. build 5664)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

import matplotlib

import matplotlib.pyplot

RuntimeError: module compiled against ABI version 2000000 but this version of numpy is 1000009

Traceback (most recent call last):

File “”, line 1, in

File “/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/pyplot.py”, line 23, in

from matplotlib.figure import Figure, figaspect

File “/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/figure.py”, line 16, in

import artist

File “/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/artist.py”, line 6, in

from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath

File “/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/transforms.py”, line 34, in

from matplotlib._path import affine_transform

ImportError: numpy.core.multiarray failed to import

···

Well, on my Linux system, when I get that error, it happens when I do
an update of numpy, but fail to rebuild mpl. Here is the order how I
build things: numpy, scipy, matplotlib. I would imagine ipython goes
last.

Ben Root

···

On Monday, December 13, 2010, Uri Laserson <laserson@...1166...> wrote:

Can you try importing pyplot from a regular python prompt? If that
works, then the issue is with ipython messing up the import process of
mpl.

I get exactly the same problem...

laserson@...2710...:~$ pythonPython 2.7.1 (r271:86832, Dec 13 2010, 14:21:05) [GCC 4.2.1 (Apple Inc. build 5664)] on darwinType "help", "copyright", "credits" or "license" for more information.

import matplotlib>>> import matplotlib.pyplotRuntimeError: module compiled against ABI version 2000000 but this version of numpy is 1000009Traceback (most recent call last):

File "<stdin>", line 1, in <module> File "/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/pyplot.py", line 23, in <module> from matplotlib.figure import Figure, figaspect

File "/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/figure.py", line 16, in <module> import artist File "/Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/artist.py", line 6, in <module>

from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath  File &quot;/Users/laserson/matplotlib/lib/python2\.7/site\-packages/matplotlib/transforms\.py&quot;, line 34, in &lt;module&gt;

from matplotlib\.\_path import affine\_transformImportError: numpy\.core\.multiarray failed to import&gt;&gt;&gt;

Well, on my Linux system, when I get that error, it happens when I do

an update of numpy, but fail to rebuild mpl. Here is the order how I

build things: numpy, scipy, matplotlib. I would imagine ipython goes

last.

That has been my order as well. How can I track down why the import of numpy.core.multiarray is causing the problem? And why would it cause a problem only when MPL is being imported, but not if I import it manually?

Originally, I tried to build the GitHub trunk version of numpy, but then abandoned that. Since MPL is saying that it was built against the 20000… ABI rather than the 10000… ABI, is it possible the MPL is finding some other version of numpy lying around? However, I’m pretty sure I deleted everything from the git numpy build. How could I pinpoint which numpy libraries are being linked against in the MPL build?

Uri

Uri,

“is it possible the MPL is finding some other version of numpy lying around?”

Yes, this is really the only remaining explanation. To find out which numpy is being used for the build process, I think if you save the output of the build process for mpl, I am fairly sure that that information is somewhere near the beginning of the build log.

Ben Root

···

On Mon, Dec 13, 2010 at 5:54 PM, Uri Laserson <laserson@…3368…> wrote:

Well, on my Linux system, when I get that error, it happens when I do

an update of numpy, but fail to rebuild mpl. Here is the order how I

build things: numpy, scipy, matplotlib. I would imagine ipython goes

last.

That has been my order as well. How can I track down why the import of numpy.core.multiarray is causing the problem? And why would it cause a problem only when MPL is being imported, but not if I import it manually?

Originally, I tried to build the GitHub trunk version of numpy, but then abandoned that. Since MPL is saying that it was built against the 20000… ABI rather than the 10000… ABI, is it possible the MPL is finding some other version of numpy lying around? However, I’m pretty sure I deleted everything from the git numpy build. How could I pinpoint which numpy libraries are being linked against in the MPL build?

Uri

Strangely, it appears to find the correct numpy.

More strangely, I picked a random order of doing things and suddenly it all works. I think what I ended up doing is this:

Following builds using default setting without changing anything except:

MACOSX_DEPLOYMENT_TARGET=10.6

python 2.7

numpy 1.5.1 with the flag --fcompiler=gnu95

mpl from github, setting the flags as I have posted earlier

then set these flags:

export MACOSX_DEPLOYMENT_TARGET=10.6

export CFLAGS=“-arch i386 -arch x86_64”

export FFLAGS=“-m32 -m64”

export LDFLAGS=“-Wall -undefined dynamic_lookup -bundle -arch i386 -arch x86_64 -framework Accelerate”

then build scipy 0.8.0 with --fcompiler=gnu95

Then it all worked. Honestly, I don’t understand why it should work because of this voodoo, but I am happily making figures now…

Also of note, supposedly scipy 0.8 has problems with python 2.7. Version 0.9 should solve these problems (currently in beta).

Thanks for the help!

Uri

Uri Laserson
Graduate Student, Biomedical Engineering
Harvard-MIT Division of Health Sciences and Technology

M +1 917 742 8019
laserson@…1166…

···

On Tue, Dec 14, 2010 at 17:03, Benjamin Root <ben.root@…1304…> wrote:

On Mon, Dec 13, 2010 at 5:54 PM, Uri Laserson <laserson@…1166…> wrote:

Well, on my Linux system, when I get that error, it happens when I do

an update of numpy, but fail to rebuild mpl. Here is the order how I

build things: numpy, scipy, matplotlib. I would imagine ipython goes

last.

That has been my order as well. How can I track down why the import of numpy.core.multiarray is causing the problem? And why would it cause a problem only when MPL is being imported, but not if I import it manually?

Originally, I tried to build the GitHub trunk version of numpy, but then abandoned that. Since MPL is saying that it was built against the 20000… ABI rather than the 10000… ABI, is it possible the MPL is finding some other version of numpy lying around? However, I’m pretty sure I deleted everything from the git numpy build. How could I pinpoint which numpy libraries are being linked against in the MPL build?

Uri

Uri,

“is it possible the MPL is finding some other version of numpy lying around?”

Yes, this is really the only remaining explanation. To find out which numpy is being used for the build process, I think if you save the output of the build process for mpl, I am fairly sure that that information is somewhere near the beginning of the build log.

Ben Root