(Last updated on May 8, 2016: syntax highlight added)


The Python distribution that comes with Mac OS X is notorious in that it is not easy to update or install modules, and that there is often a dependency issue for applications not preinstalled. Therefore, for OS X users it's usually recommended that using package managers such as MacPorts and Homebrew instead, installing Python therein, and avoiding using the system Python. A better solution for novices is to install an independent Python distribution, including Anaconda and Enthought.

While most of solutions are available for free, it seems a bit redundant to me to have multiple copies of Python. Sometimes I was confused which Python I was using. Therefore, after a clean installation I decided to test how much the system Python can do. The example I chose is to install a module called IPython which is not preinstalled on OS X and provides a graphical notebook interface similar to Mathematica. The procedure below has been tested on Mac OS X 10.10.3.

After some trial and error I realized that it is impossible to install it with the easy_install command. But pip, however, can be installed by easy_install. Therefore, one can do
[code gutter="false" language="bash"]
sudo easy_install pip
sudo pip install ipython[all]
[/code]
We need sudo because the packages are installed in the system folder which only the root can access. The [all] tag in the second line tells pip to install everything that IPython may depend on. After installation one should be able to execute ipython in the command line. For a graphical interface, run ipython notebook instead.

Some users may run into a problem in which the zmq module is missing (see a related discussion). A possible reason is that the zmq (or pyzmq) module has been previously installed by easy_install, whose egg version is incompatible with IPython (as of ver 3.1.0) and hence not recognized by IPython. The solution is to remove and re-install it using pip:
[code gutter="false" language="bash"]
sudo pip uninstall pyzmq
sudo pip install pyzmq
[/code]
And one can test it by import zmq under the Python command line. It should work if the installation is successful.

One more thing: the --pylab flag in IPython has been deprecated (as of ver 3.1.0). One should instead execute %pylab in the notebook interface. If one wants the plots to be shown in the notebook interface rather than in a separated window, use %pylab inline.