When working with scientific data, NumPy, SciPy etc. are often used. They can be quite a pain in the ass to setup: many dependencies, some modules have to be compiled (which sometimes works…), so often PIP does not work out of the box. Also, the Apple Developer Command Line Tools have to be installed for this to use the compilers.

The very simple solution to this is Anaconda, a Python distribution containing almost anything would ever want: NumPy, Skikit-Learn, and also file format libraries like H5Py.

Just grab the installer here. I choose to install it into my home folder, so the anaconda python interpreter is to be found as $HOME/anaconda/bin/python.

If you want to have an additional package in the distribution which is available via PIP, just use the distributions pip:

$HOME/anaconda/bin/pip install somepackage

Anaconda also has its own package management system, conda. To install OpenCV, for example:

$HOME/anaconda/bin/conda install -c https://conda.binstar.org/jjhelmus opencv

I have written a little wrapper script for using the anaconda interpreter:

#!/bin/bash
    
run="$1"
[ -z "$1" ] && run='process.py'
    
if [ "$run" = 'repl' ]; then
    run=''
fi
    
if [ -x "$HOME/anaconda/bin/python" ]; then
    "$HOME/anaconda/bin/python" $run
else
    python $run
fi

Per default, it tries to run a script called process.py. ./run.sh repl starts the Python REPL.