Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install numpy and scipy on OSX?

I'm new to Mac so please bear with me.

I'm using snow leopard 10.6.4 at the moment.

I want to install numpy and scipy, so I downloaded the python2.6,numpy and scipy dmg files from their official site. However, I'm having problem import numpy:

Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/multiarray.so: no matching architecture in universal wrapper

Can anyone shed some light to this problem?

like image 801
goh Avatar asked Dec 24 '10 16:12

goh


People also ask

How do I install a scipy module in Python?

Type and run pip install scipy in the command prompt. This will use the Python Package index, and install the core SciPy packages on your computer. You can also install other core packages like Numpy and Matplotlib by using the pip install numpy and pip install matplotlib commands.

Does numpy work on Mac?

NumPy can be installed with conda , with pip , with a package manager on macOS and Linux, or from source. For more detailed instructions, consult our Python and NumPy installation guide below.


2 Answers

Sounds as though you might be trying to use a 32-bit library from a 64-bit Python. Looks like there's an unofficial 64-bit Numpy available for Snow Leopard.


EDIT: The Python 2.6 .dmg available here is indeed 32-bit. (Specifically, it's a universal binary containing both i386 and ppc versions). The same is true of the regular numpy and scipy .dmg releases available here. (How do I know? See below!) So if you use those releases together you should be fine.

But you're not fine - so my guess is you're not using the version of Python from the 2.6 .dmg you downloaded. If you're running an executable python script, e.g.:

$ ./my-script.py

then you could try specifying the Python you're using explicitly on the command line. Looks like the MacPython .dmg installs to /usr/local/bin/python, so try:

$ /usr/local/bin/python2.6 myscript.py

Any joy?


How I determined the architecture the contents of those .dmg files are built for...

  1. Mount the .dmg (i.e. double-click it to open a volume)
  2. Use gunzip and pax to unpack the package contents to a local directory, e.g.:

    $ mkdir tmp
    $ cd tmp
    $ gunzip -c /Volumes/Universal\ MacPython\ 2.6/MacPython.mpkg/Contents/Packages/PythonUnixTools-2.6.pkg/Contents/Archive.pax.gz | pax
    
  3. Use file to examine binary files in the package contents

    $ file Versions/2.6/bin/python
    Versions/2.6/bin/python: Mach-O universal binary with 2 architectures
    Versions/2.6/bin/python (for architecture ppc): Mach-O executable ppc
    Versions/2.6/bin/python (for architecture i386):    Mach-O executable i386
    
like image 81
Simon Whitaker Avatar answered Sep 20 '22 12:09

Simon Whitaker


I had the same error message when I was trying my freshly-installed numpy and scipy in python2.7 on Mac OSX 10.6.8 . Later I found out that there were two .dmg for python2.7:

  • numpy-1.6.2-py2.7-python.org-macosx10.3.dmg
  • numpy-1.6.2-py2.7-python.org-macosx10.6.dmg

It was the package in 10.3.dmg giving me the error message about multiarray.so. After installing the one in 10.6.dmg, I got rid of this error message.

like image 26
Po C. Avatar answered Sep 20 '22 12:09

Po C.