tl;dr
- Install Xcode from the App Store, then install the Command Line Tools from Xcode (Preferences | Downloads | Components).
- Install Homebrew, gfortran, pip, readline, python, numpy, ipython, and whichever packages you need:
- There is no step 3. No setting up symlinks, monkeying with your PATH, etc. And, except for that first step of getting your compiler toolchain (Xcode) and package manager (brew) set up, none of it's Mac-specific.
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" brew install gfortran sudo easy_install pip readline sudo pip install --upgrade --force-reinstall numpy sudo pip install ipython scipy pandas matplotlib
But I'm using an older OS X that doesn't have Python 2.7
Then this guide isn't for you. Sorry.Why do I have to force-upgrade numpy?
Depending on your OS X version, you may have numpy pre-installed. (Also, a lot of people seem to get numpy installed on their own before running into problems with other packages.) The problem is that if you install numpy with Fortran support disabled, this will cause problems when you install scipy. So, after installing Fortran, upgrade numpy.
(Plus, at the time of this posting, 1.7.0 is pretty new, so if you have it, you probably have 1.6.x.)
Isn't 2.7.2 out of date?
If you need any of the fixes mentioned on the 2.7.3 Release page or Change log, you will have to install 2.7.3 and follow a different guide.I want to use Python 3, or PyPy, or…
For 3.x, see Installing scipy, etc., for Python 3 on Mac.For PyPy, as far as I know, numpypy is still a work in progress. If you're willing to assist the development (even just by testing), they'd probably love your help.
For other non-CPython versions like Jython and IronPython, you're out of luck—you'll probably want to find JVM or .NET numeric and scientific libraries and use them instead.
But what about all those 300-line blog posts that say it's easier to start with the python.org installer?
Do they look easier?All that stuff they make you do monkeying with your PATH or manually setting up symlinks is only necessary because you're setting up another copy of Python 2.7 in parallel with the one Apple already gave you. If you don't do that, you don't have to deal with all that complexity.
If you want to do it anyway, go ahead. But I'd recommend learning what you're actually doing with your PATH—what the difference is between setting it in profile vs. bash_profile, ~/.profile vs. /etc/profile, profile vs. environment.plist, etc.
And, when you go looking for help, the general Python community is not going to be able to help you. The scipy community may actually be able to help you. But nobody ever goes there. Instead, they go to python-list or StackOverflow. Linux and Windows users never have two system-wide Python 2.7 installs. Mac users do, but they all followed one of those same blog posts you did, and all they know is that it works for them.
So, when you inevitably show up on StackOverflow to post the 500th question this year asking "Why is scipy broken?", at least have this information in advance, and put it in your question:
- Which blog post did you follow (with a link)?
- What OS X are you on, and does it have an Apple Python 2.7 (/usr/bin/python)?
- Which additional Python 2.7 did you install (e.g., python.org 64-bit installer, Homebrew package, etc.), and what options did you use?
- What does "echo $PATH" say from the shell? (And, if your problem is running "import scipy" after an install seemed to work, what does "print(sys.path)" say from Python?)
- What command failed, and what is the complete error?
If you don't, you will spend hours answering these questions (especially since nobody has ever answered all of them at once—for some reason people seem to feel that answering 1.5 questions out of 5 is sufficient), or you will get irrelevant or even incorrect answers that lead you to waste hours screwing up your system even worse.
Add a comment