Pippi
Pippi

Reputation: 2571

Numpy installation API version mismatch

I want to install numpy, pylab, scipy, and ipython on Mac OS X Lion. I installed the following:

python-2.7.3-macosx10.6.dmg, 
numpy-1.6.1-py2.7-python.org-macosx10.6.dmg, 
matplotlib-1.1.1-py2.7-python.org-macosx10.6.dmg, 
scipy-0.11.0-py2.7-python.org-macosx10.6.dmg

and obtained the following messages:

/var/folders/hm/bv37669175j2dvn_f87t4zcc0000gn/T/Cleanup\ At\ Startup/statistics_intro-373260522.639.py.command ; exit;
RuntimeError: module compiled against API version 6 but this version of numpy is 4
Traceback (most recent call last):
...
    from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/transforms.py", line 34, in <module>
    from matplotlib._path import affine_transform
ImportError: numpy.core.multiarray failed to import

Many users appear to be able to get numpy working by removing python and reinstall. I did that in /user/bin and /Library, but I still receive the error message.

Upvotes: 0

Views: 2876

Answers (3)

zmo
zmo

Reputation: 24802

The best way to do it is using homebrew

Basically, to get what you want, here are the steps, as root in a shell:

ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
brew install python # install python2.7
pip install numpy matplotlib scipy

and it should just work.

Upvotes: 1

Pippi
Pippi

Reputation: 2571

Thanks all. I had Mac OS (1) Upgrade from Lion to Mountain Lion (2) update Python (3) had it point to Python27 instead of system Python. This doesn't explain why Python in Lion is broken, but I no longer receive the error messages!

Upvotes: 0

Pierre GM
Pierre GM

Reputation: 20359

Relying on .dmg is asking for disappointment, as your personal setup may not match the one of the person who prepared the .dmg. You should really consider installing the different packages from their sources. Download the archives you want, decompress them and in each package run a

python setup.py install --user

(the --user ensuring that the packages will be installed in ~/.local). Of course, you'll want to start with numpy, then scipy, then matplotlib and then ipython. Then, just make sure you add ~/.local to your PYTHONPATH.

The operation, although a bit long, should be relatively painless. Make sure you have all the tools needed for the compilation, though (XCode is a must and you'll also need a fortran compiler).

Upvotes: 1

Related Questions