Update: These instructions are over a year old, though they may still work for you. See the “Install Python” page for the most recent instructions.
A bit ago a friend and I both had fresh Mac OS X Lion installs so I helped him set up his computers with a scientific Python setup and did mine at the same time.
These instructions are for Lion but should work on Snow Leopard or Mountain Lion without much trouble. On Snow Leopard you won’t install Xcode via the App Store, you’ll have to download it from Apple.
After I’d helped my friend I found this blog post describing a procedure pretty much the same as below.
Update: If doing all the stuff below doesn’t seem like your cup of tea, it’s also possible to install Python, NumPy, SciPy, and matplotlib using double-click binary installers (resulting in a much less flexible installation), see this post to learn how.
Xcode
You will need Apple’s developer tools in order to compile Python and the other installs. On Lion you can install Xcode from the App Store, on Snow Leopard you’ll have to get an older Xcode from developer.apple.com.
I use the Xcode editor because I like its syntax highlighting, code completion, and organizer. However, I use hardly any of its features and unless you’re an iOS or Mac developer you probably won’t either. If you prefer another editor it’s possible to get only the libraries and compilers that you need with the Command Line Tools for Xcode. (You’ll need a free Apple ID.) (See also http://www.kennethreitz.com/xcode-gcc-and-homebrew.html.)
Homebrew
Homebrew is an excellent package manager for Mac OS X that can install a large number of packages. To install it simply launch a terminal and enter
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
Homebrew installs things to /usr/local/ so you don’t need sudo permissions. To add Homebrew installed executables and Python scripts to your path you’ll want to add the following line to your .profile (or .bash_profile) file:
export PATH=/usr/local/bin:/usr/local/share/python:$PATH
Normal executables go in /usr/local/bin/ and Python scripts installed by Homebrew go in /usr/local/share/python/.
See https://github.com/mxcl/homebrew/wiki/The-brew-command or type brew help or man brew for more info on Homebrew.
Install Python
Now that you’ve got Homebrew installing Python is simple:
brew install python
Homebrew will install a couple of packages required by Python and then Python itself. Don’t be surprised if this takes a couple minutes.
Important: You should close your terminal and open a fresh one right now so that it has the updated PATH from the previous section. Otherwise you run the risk of executing the wrong scripts during the rest of these instructions.
At this point you should be able to get a fresh terminal and type
which python
and see
/usr/local/bin/python
Homebrew is for installing system packages and tools; for managing Python add-ons we want pip. Luckily easy_install, another Python package manager is installed by Homebrew and we can use it to install pip:
easy_install pip
Install NumPy
Use pip to install NumPy:
pip install numpy
This should install NumPy 1.6.1 (as of Feb. 2012).
Install SciPy
We need gfortran to compile SciPy but it is not included with the other Xcode tools. Luckily, Homebrew can help us out again:
brew install gfortran
When that’s done it’s a cinch to install SciPy:
pip install scipy
This should install SciPy 0.10.
Install matplotlib
To install matplotlib we need to revisit Homebrew one more time:
brew install pkg-config
And the usual pip command:
pip install matplotlib
This should install matplotlib 1.2.0. If it doesn’t you can try installing from the matplotlib development repo:
pip install git+git://github.com/matplotlib/matplotlib.git
Congratulations! You should now have the basics of a scientific Python installation that’s easy to manage and upgrade using Homebrew and pip. Fire up Python and make sure things worked. The following should work in Python with no errors:
import numpy import scipy import matplotlib
Enjoy!

On latest lion with command line compiler tools installed, matplotlib installation fails:
agg24/include/agg_renderer_outline_aa.h:1368:45: error: binding of reference to type ‘agg::line_profile_aa’ to a value of type ‘const agg::line_profile_aa’ drops qualifiers
line_profile_aa& profile() { return *m_profile; }
^~~~~~~~~~
1 error generated.
error: command ‘/usr/bin/clang’ failed with exit status 1
I tried replacing clang with llvm-gcc-4.2 (just overwrite temporarily clang) — same thing.
Any ideas?
Which command did you use to install matplotlib, and did you notice what version it’s trying to install?
I tried both:
pip install matplotlib
that tried to install:
matplotlib: 1.1.0
python: 2.7.2 (default, Feb 25 2012, 09:03:36) [GCC 4.2.1
Compatible Apple Clang 3.1
(tags/Apple/clang-318.0.45)]
platform: darwin
and
pip install git+git://github.com/matplotlib/matplotlib.git
no difference in result.
It looks like this is a known bug in matplotlib that should be fixed soon. In fact, it looks like it’s already been fixed in the development version. You might try reinstalling from github. You might also want to take a look at this thread from a few days ago.
I’m not sure why your matplotlib is building with clang. I just did
pip install matplotlibon my machine and it compiles withllvm-gcc.(looks like deeper replies are not allowed)
The latest github state passes: Yay – thank you!
It’d be better to write this as a single Ruby script and post the one command that any Mac user can run to install everything from scratch.
Please do!
Matt – thanks for writing this. I’d been meaning to get started with Python for months, and this easy tutorial gave me motivation to do it.
Couple things:
(1) I had trouble with the curl command at the very beginning for homebrew; with help from an officemate, we fixed that by copying the script to a .rb file and running it with /usr/bin/ruby.
(2) Everything appeared to install fine, and I did a rehash, but after starting python and trying to import the new packages I get:
ImportError: No module named numpy
Thoughts on that?
One thing is to make sure you’ve started the right Python. If you type
which pythonin a terminal do you get/usr/local/bin/python? If instead you get/usr/bin/pythonthen you want to set yourPATHas described in the Homebrew section above.If you’ve got the right Python but still no NumPy check this directory, that’s where it should be installed:
/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/. If you don’t see it there then it was probably installed somewhere else for some reason. You’ll again want to check yourPATHand make sure you’re using the right easy_install and pip.which pipshould give/usr/local/share/python/pip. If you get a different pip you’ll again want to make sure you’ve got yourPATHset correctly and start again from theeasy_install pipstep.I installed numpy but from there onwards everything is bad! When I do which pip I get “/usr/local/bin/pip”. When I go into /usr/local/Cellar/python/2.7.3 there isn’t even a lib file! Any ideas? This is my .bash_profile:
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH=”/usr/local/bin/python:${PATH}”
export PATH=/usr/local/bin:/usr/local/share/python:$PATH
Sorry to be a hassle! I really need to get this working asap. Thanks, Nick
Except for the fact that you don’t need to put
/usr/local/bin/pythonon yourPATHthis all looks fine. What exact errors are you seeing?I have the same problem as Nick,
pip is installed in /usr/local/bin/pip, but links to pip inside the Cellar, so that seems OK.
problems start when installing scipy, starting with:
umfpack_info:
libraries umfpack not found in /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib
libraries umfpack not found in /usr/local/lib
libraries umfpack not found in /usr/lib
/usr/local/lib/python2.7/site-packages/numpy/distutils/system_info.py:470: UserWarning:
UMFPACK sparse solver (http://www.cise.ufl.edu/research/sparse/umfpack/)
not found. Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [umfpack]) or by setting
the UMFPACK environment variable.
warnings.warn(self.notfounderror.__doc__)
NOT AVAILABLE
and much more packages that can’t be found after that
The /usr/local/Cellar/python/2.7.3/Frameworks/Python.framwork/Versions/2.7/lib folder doesn’t exist, as nick stated. Has something changed in the current version? I don’t get it…
Ahhh sorry for not doing enough googling:
fixed it by manually compiling numpy and then installing with:
python setup.py install –prefix=/usr/local
cheers,
Lennard
Glad you got it working! Homebrew installs pip to
/usr/local/share/pythonso it’s odd you have one in/usr/local/bin. That may be part of the issue and manually installing NumPy works around it.as far as I know numpy now installs with the python from homebrew, I made sure I deleted all other versions of python. Also /usr/local/bin/python links to the Cellar. In /usr/local/lib/python2.7/ there are libraries needed for compiling scipy for instance.
Although scipy now compiles, scipy.test() results in 50+ errors. Apparently it’s a known bug, something to do with gfortran and the like with macosx, didn’t find anything on how to solve it yet.
If you run an matplotlib example, you may find the script though not showing any errors, just hanges and does not plotting anything.
Edit ~/.matplotlib/matplotlibrc and add:
backend: MacOSX
Worked for me.
Pingback: Install Python, NumPy, SciPy, and matplotlib on Mac OS X – Double Click | Pen and Pants
Thanks for the post, it motivated me to finally get all this installed on my mac. It seems the url for installing homebrew has changed, though. https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb worked for me (March 24).
Thanks for letting me know!
btw pointed a few ppl your way – http://www.astrobetter.com/learning-python-the-interactive-way/
Thanks for the great post.
It could be nice to advice to run `brew doctor` and remove old dependencies for systems that are not clean. Otherwise installing `pkg-config` and `gfortran` can be useless (because shadowed by old libraries).
Hey Matt!
I really appreciate the instructions you’ve been posting on here. It was super-convenient to use the double-click install on my work machine, however I wish that python had tab completion (presumably from readline). Does this “CIY” version compile with readline, or support tab completion some other way?
Thanks!
If you want tab completion you’ll want IPython: http://ipython.org/. The IPython HTML Notebook is highly recommended.
You should be able to install IPython regardless of which method you used to install Python, etc.
That’s awesome you’re using Python at work! Good to hear from you!
Yeah, after seeing the HTML Notebook on your site that’s my goal–I have some class exercises in IDL I’d like to rewrite in python. So you totally answered my question, but I asked something different that what I intended. =) I’m actually looking for the unix-like command line editing that I believe readline provides. I’m wondering if that just works with the CIY method.
I also have just learned that, apparently, the libedit library on OS X can provide this, and it may be possible to turn that on post-install with just a configuration file.
Thanks, I appreciate you sharing your expertise! The last time I installed a computer with all my analysis software was more than a few years ago, and a lot has changed since then!
Homebrew does compile Python against readline so all of the Control-letter commands work in the interactive interpreter. However, I’d recommend the IPython notebook regardless.
I had trouble with scipy, this was necessary: pip install -e git+https://github.com/scipy/scipy#egg=scipy-dev
This article save my life. Thank you so much.
Glad to help!
Hi Matt,
This is awesome. Thanks so much. These were the changes to your directions above that I had to make, all very painless:
Homebrew url changed again. I used: /usr/bin/ruby -e “$(/usr/bin/curl -fsSkL raw.github.com/mxcl/homebrew/go)”
I didn’t have to do: brew install pkg-config, apparently pkg-config was already installed.
I’m adding some comments to your Mountain Lion Post as well, I ran into more problems than you did.
-Azalee
I follow your post to install python and numpy.
I successfully installed python on my mac book (Mac OS X Lion 10.7.5) but after running the command pip install numpy I get this error:
Downloading/unpacking numpy
Running setup.py egg_info for package numpy
Running from numpy source directory.non-existing path in ‘/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils’: ‘site.cfg’
F2PY Version 2
blas_opt_info:
FOUND:
extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
define_macros = [('NO_ATLAS_INFO', 3)]
extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']
lapack_opt_info:
FOUND:
extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
define_macros = [('NO_ATLAS_INFO', 3)]
extra_compile_args = ['-msse3']
build_src
building py_modules sources
building library “npymath” sources
customize NAGFCompiler
Could not locate executable f95
customize AbsoftFCompiler
Could not locate executable f90
Could not locate executable f77
customize IBMFCompiler
Could not locate executable xlf90
Could not locate executable xlf
customize IntelFCompiler
Could not locate executable ifort
Could not locate executable ifc
customize GnuFCompiler
Could not locate executable g77
customize Gnu95FCompiler
Could not locate executable gfortran
customize G95FCompiler
Could not locate executable g95
customize PGroupFCompiler
Could not locate executable pgfortran
don’t know how to compile Fortran code on platform ‘posix’
C compiler: xcrun clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
compile options: ‘-I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/src/private -I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/src -I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core -I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/src/npymath -I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/src/multiarray -I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/src/umath -I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/include -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c’
xcrun: _configtest.c
xcrun clang _configtest.o -o _configtest
ld: library not found for -lcrt1.10.6.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: library not found for -lcrt1.10.6.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
failure.
removing: _configtest.c _configtest.o
Traceback (most recent call last):
File “”, line 16, in
File “/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/setup.py”, line 214, in
setup_package()
File “/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/setup.py”, line 207, in setup_package
configuration=configuration )
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils/core.py”, line 186, in setup
return old_setup(**new_attr)
File “/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py”, line 152, in setup
dist.run_commands()
File “/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py”, line 953, in run_commands
self.run_command(cmd)
File “/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py”, line 972, in run_command
cmd_obj.run()
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils/command/egg_info.py”, line 8, in run
self.run_command(“build_src”)
File “/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py”, line 326, in run_command
self.distribution.run_command(command)
File “/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py”, line 972, in run_command
cmd_obj.run()
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils/command/build_src.py”, line 152, in run
self.build_sources()
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils/command/build_src.py”, line 163, in build_sources
self.build_library_sources(*libname_info)
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils/command/build_src.py”, line 298, in build_library_sources
sources = self.generate_sources(sources, (lib_name, build_info))
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils/command/build_src.py”, line 385, in generate_sources
source = func(extension, build_dir)
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/setup.py”, line 696, in get_mathlib_info
raise RuntimeError(“Broken toolchain: cannot link a simple C program”)
RuntimeError: Broken toolchain: cannot link a simple C program
Complete output from command python setup.py egg_info:
Running from numpy source directory.non-existing path in ‘/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils’: ‘site.cfg’
F2PY Version 2
blas_opt_info:
FOUND:
extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
define_macros = [('NO_ATLAS_INFO', 3)]
extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']
lapack_opt_info:
FOUND:
extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
define_macros = [('NO_ATLAS_INFO', 3)]
extra_compile_args = ['-msse3']
running egg_info
running build_src
build_src
building py_modules sources
building library “npymath” sources
customize NAGFCompiler
Could not locate executable f95
customize AbsoftFCompiler
Could not locate executable f90
Could not locate executable f77
customize IBMFCompiler
Could not locate executable xlf90
Could not locate executable xlf
customize IntelFCompiler
Could not locate executable ifort
Could not locate executable ifc
customize GnuFCompiler
Could not locate executable g77
customize Gnu95FCompiler
Could not locate executable gfortran
customize G95FCompiler
Could not locate executable g95
customize PGroupFCompiler
Could not locate executable pgfortran
don’t know how to compile Fortran code on platform ‘posix’
C compiler: xcrun clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
compile options: ‘-I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/src/private -I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/src -I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core -I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/src/npymath -I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/src/multiarray -I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/src/umath -I/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/include -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c’
xcrun: _configtest.c
xcrun clang _configtest.o -o _configtest
ld: library not found for -lcrt1.10.6.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: library not found for -lcrt1.10.6.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
failure.
removing: _configtest.c _configtest.o
Traceback (most recent call last):
File “”, line 16, in
File “/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/setup.py”, line 214, in
setup_package()
File “/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/setup.py”, line 207, in setup_package
configuration=configuration )
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils/core.py”, line 186, in setup
return old_setup(**new_attr)
File “/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py”, line 152, in setup
dist.run_commands()
File “/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py”, line 953, in run_commands
self.run_command(cmd)
File “/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py”, line 972, in run_command
cmd_obj.run()
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils/command/egg_info.py”, line 8, in run
self.run_command(“build_src”)
File “/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py”, line 326, in run_command
self.distribution.run_command(command)
File “/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py”, line 972, in run_command
cmd_obj.run()
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils/command/build_src.py”, line 152, in run
self.build_sources()
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils/command/build_src.py”, line 163, in build_sources
self.build_library_sources(*libname_info)
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils/command/build_src.py”, line 298, in build_library_sources
sources = self.generate_sources(sources, (lib_name, build_info))
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/distutils/command/build_src.py”, line 385, in generate_sources
source = func(extension, build_dir)
File “/private/var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy/numpy/core/setup.py”, line 696, in get_mathlib_info
raise RuntimeError(“Broken toolchain: cannot link a simple C program”)
RuntimeError: Broken toolchain: cannot link a simple C program
—————————————-
Command python setup.py egg_info failed with error code 1 in /var/folders/k9/3cg3j23s0slbwbym9fkshj9r0000gn/T/pip-build/numpy
Can you please help me with this.
Thanks
A commenter on another of my posts recommends this answer on StackOverflow: http://stackoverflow.com/a/14131249/1405710
thanks totally worked for me.
Thanks a bunch for this concise and correct guide to getting Python up and running on Mac. Was having a ‘mare with a clean install and following this sorted it right out!
Hi all … I have some tradition in building numpy/scipy (with optimized libs like suite-sparse) on the Mac (and Linux earlier). When I learned about Homebrew, I started to join the project to improve Python support and make the “scipy-superpack” kind of obsolete.
We know `pip` is bad at pulling dependencies. Therefore, I’d like to introduce my own Homebrew “tap” (=easy-to-add repo of additional formulae) at https://github.com/samueljohn/homebrew-python.
I can support you there (just open an issue) when you get into trouble (instead of spamming in this comments thread :-)
You can then:
`brew tap samueljohn/python`
and `brew install numpy scipy matplotlib pillow` (may tell you that you need to `pip install nose` because homebrew does not aim to include pure python modules that build just fine with pip). If you love bleeding edge, you may want to try `brew install numpy –HEAD`.
I’d love to get your feedback and suggestions. This is my little contribution to the Python community. Hope my homebrew scripts may save you the one or the other minute in getting a decent scientific Python setup on the Mac.
Looks neat, thanks for sharing!
hello,
thanks for the guide but i have prolem installing matplotlib.
i followed your instructions but got stocked at “pip install matplotlib”..here is the error message.
using the first option(pip install matplotlib), i get:
pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri', 'matplotlib.delaunay', 'pytz', 'dateutil', 'dateutil.zoneinfo']
warning: no files found matching ‘KNOWN_BUGS’
warning: no files found matching ‘INTERACTIVE’
warning: no files found matching ‘make.osx’
warning: no files found matching ‘MANIFEST’
warning: no files found matching ‘__init__.py’
warning: no files found matching ‘examples/data/*’
warning: no files found matching ‘lib/mpl_toolkits’
warning: no files found matching ‘lib/matplotlib/mpl-data/matplotlib.conf’
warning: no files found matching ‘lib/matplotlib/mpl-data/matplotlib.conf.template’
warning: manifest_maker: MANIFEST.in, line 16: ‘recursive-include’ expects …
warning: no files found matching ‘LICENSE*’ under directory ‘license’
Installing collected packages: matplotlib
Running setup.py install for matplotlib
basedirlist is: ['/usr/local/', '/usr', '/usr/X11', '/opt/local']
second options(downloading for the website), i get:
freetype2: found, but unknown version (no pkg-config)
cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/local/include -I/usr/include -I/usr/X11/include -I/opt/local/include -I/usr/local/include -I/usr/include -I. -I/usr/local/lib/python2.7/site-packages/numpy/core/include -I. -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/_png.cpp -o build/temp.macosx-10.8-x86_64-2.7/src/_png.o
src/_png.cpp:23:13: fatal error: ‘png.h’ file not found
# include
^
1 error generated.
error: command ‘cc’ failed with exit status 1
—————————————-
Command /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c “import setuptools;__file__=’/private/var/folders/7q/0s9d01f50gn_j01xd2_709jh0000gn/T/pip-build-Eberechi/matplotlib/setup.py’;exec(compile(open(__file__).read().replace(‘\r\n’, ‘\n’), __file__, ‘exec’))” install –record /var/folders/7q/0s9d01f50gn_j01xd2_709jh0000gn/T/pip-C70ej3-record/install-record.txt –single-version-externally-managed failed with error code 1 in /private/var/folders/7q/0s9d01f50gn_j01xd2_709jh0000gn/T/pip-build-Eberechi/matplotlib
Storing complete log in /Users/Eberechi/.pip/pip.log
thank you,hope you can help me. thank you
regards
I’d stick with “pip install matplotlib”, I just tried it and it worked for me installing version 1.2.1. I got very similar output to you but at the end it said “Successfully installed matplotlib”.
Pingback: Install Scientific Python on Mac OS X | Pen and Pants
Pingback: How To Install Matplotlib On OS X? | Click & Find Answer !
You may want to add a missing piece:
brew install swig
SciPy installation would not proceed without it.
How were you installing SciPy? I’ve never seen that before and I’m pretty sure swig is not necessary to install SciPy.
FYI: I got this error installing matplotlib:
fatal error: ‘ft2build.h’ file not found
Fixed it by installing freetype and libpng via homebrew.