4

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,

2
  • 2
    is the numpy that comes with osx not sufficient? Commented Sep 7, 2011 at 17:48
  • Sometimes it is not, for some software packages. Commented Feb 12, 2012 at 6:03

9 Answers 9

13

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
Sign up to request clarification or add additional context in comments.

Comments

7

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.

Comments

3

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.

Comments

3

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

Comments

2

The easiest way that I found was to visit http://sourceforge.net/projects/numpy/files/NumPy/, pick the folder of the latest version, and then download the .dmg file that matched my installed version of Python.

2 Comments

somehow this was the best option. Awesome!
this works, but notice you want a .dmg file like in El Developer's answer, but you want the OS 10.6 version not the OS 10.3 version that El Developer linked to.
0

Based on this post, I found that Chris Fonnesbeck keeps a highly functional installer script for OSX 10.7 at the OSX SuperPack Github site.

Because I hapened to have all the dependencies (such as gfortran) already, I did not use his full shell script. Rather I just did

git clone --depth=1 git://github.com/fonnesbeck/ScipySuperpack.git  
python -m easy_install -N -Z ScipySuperpack/*.egg   

And it worked beautifully. In particular, it worked better than the .dmg files from the official numpy and scipy distributions, and better than pip install.

Comments

0

You can install numpy/scipy using pip, If pip is not installed on your machine, you can install it with easy_install:

sudo easy_install pip

Then install numpy:

sudo pip install numpy

Comments

0

A very easy route is to install Anaconda from Continuum, or Enthought's Canopy. These are python distributions that include numpy, as well as other useful scientific computing libraries

Comments

-4

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.