Install Numpy on Mac OS X Lion 10.7

22,221

Solution 1

Generally, unless you have a good reason you might want to avoid trying to have to build numpy/scipy et al. yourself.

For Mac's there are two nice everything-included packages for numerical python. Enthough distribution (paid, http://www.enthought.com/) and Sagemath (free, http://www.sagemath.org/). I'm happily using Sagemath on 10.7 - it has numpy, scipy etc.

Solution 2

Lion comes with numpy installed. It should already be there:

$ python -c 'import numpy, numpy.version; print numpy, numpy.version.version'
<module 'numpy' from '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/__init__.py'> 1.5.1

Solution 3

For anyone that hits this from google, here is where I figured out how to build numpy on Mac OS.

http://www.scipy.org/Installing_SciPy/Mac_OS_X

On lion, it amounts to setting some environment variables (after Xcode is installed):

export CC=gcc-4.2
export CXX=g++-4.2
export FFLAGS=-ff2c

Then pip install numpy works just fine.

Solution 4

I have used a few software packages that require a fresh install of NumPy, that won't work with the built in NumPy or even with the built-in Python. The easiest way to install NumPy on the mac is to download any of these packages. This will work for most OS versions.

Still the other answers are valid, though this is a more general answer.

This is the SourceForge page of the project.

Solution 5

If you do install Xcode you can get the latest and greatest open source libraries and packages. Consider using the excellent Mac Ports (http://www.macports.org) project. It is a package manager that will download source packages and their dependencies and build all the libraries and tools for you.

Installing Numpy becomes a one line command once Xcode and mac ports is installed:

sudo port install py27-numpy

Share:
22,221
Admin
Author by

Admin

Updated on November 10, 2020

Comments

  • Admin
    Admin over 3 years

    I need to install Numpy on my Mac OS X Lion 10.7. I googled a little bit, it seems like there are a lot of stuff needs to be installed. And some says I need install Xcode before I install Numpy. But the official website of Numpy doesn't give much information about installing Numpy on Mac. I really don't want to install Xcode as it would cost a lot space.

    So anyone knows how to install Numpy? What's the prerequisites?

    Thanks,