How to create a scientific Python environment: Sierra edition

First we start by installing GCC. It can be obtained by downloading Apple’s command line tools (you must have an Apple account) or directly XCode.

The approach I am presenting here relies heavily on homebrew as a way of avoiding dependency hell of compiling many of these tools manually. I’ve done that in the past, though.

You have to update your PATH environment, by adding the following line to your ~/.profile file:

export PATH=/usr/local/bin:/usr/local/sbin/$PATH


We can install Python 3 by typing:

$ brew install python3

This not only install Python, but also pip, setuptools, and wheels.

The way of updating them is by typing:

$ pip3 install --upgrade pip setuptools wheel

It is also good to install nose to allow testing. From now on it is all pip3 for python stuff.

numpy, scipy, and friends

Standard library for numerical Python. The rule is to turn to pip3 as much as possible to installing packages. In the case of numpy, it installs a wheel package that works well with our Python 3:

$ pip3 install numpy

And to test that everything goes well simply type:

$ python3 -c "import numpy; numpy.test()"

If this works well, then we can install all the rest of tools the same way:

$ pip3 install scipy matplotlib pandas ipython[notebook]
$ pip3 install sphinx


Cython is an optimizing static compiler for Python. It can be directly installed using pip3:

$ pip3 install cython

A cool thing of cython is that it can be interactively run in jupyter using the cycthonmagic extension:

%load_ext cython

And then simply use the magic function:


cdef int a = 0

And so on.

Installing lammps

Lammps is a powerful molecular dynamics simulation code. It can be installed using homebrew:

$ brew install lammps

This installs a bunch of other packages and dependencies as well. Examples and potentials are also downloaded. You can test it using:

$ brew test lammps -v

So far lammps’s Python extension works with Python2.

Installing Haskell

Haskell is a functional programming language. I have chosen to install the Haskell Platform via homebrew:

$ brew cask install Haskell-platform

The Haskell platform includes the Glasgow Haskell compiler, the cabal package system and the stack project management tool.

Installing Julia

The installation of Julia is straightforward: download the package directly from their site: and you are good to go.