Installing a Python distro for testing and development

From CSDMS
Revision as of 14:05, 3 January 2017 by Mpiper (talk | contribs) (Sig)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Installing Python for testing and development on beach

There are several Python distributions available on beach, but it's often useful to install a local Python distribution for testing and development. This technique is used frequently by the CSDMS software engineers; see, e.g., the article Installing a WMT executor. If things go horribly awry, you can just delete the Python distribution and start over again.

Before we start, note that the commands used in this article require the bash shell. You can determine which shell you're currently using on beach by executing this command:

echo $0

If the output from this command isn't -bash, please contact the CSDMS software engineers at CSDMSsupport@colorado.edu and we can help.

Starting in your home directory, download a Python distribution. The CSDMS software engineers recommend miniconda, a minimal distribution based on the Anaconda Python distribution. Change directories, then grab the miniconda installer with curl:

cd
curl https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -o miniconda.sh

Execute the miniconda shell script, installing into a directory named conda in your home directory.

bash ./miniconda.sh -f -b -p $HOME/conda

Then push this Python distribution to the front of your path.

PATH=$HOME/conda/bin:$PATH

To use your local Python distribution, this command will need to be executed every time you log in or open a new terminal on beach.

You now have a minimal Python distribution. Check that this Python is at the front of your path with the which command:

which python

which should return ~/conda/bin/python.


Adding packages

Your local Python distribution has only a bare minimum set of packages; not even numpy, matplotlib, or ipython are included. Use the Anaconda package manager, conda, to install a set of frequently used packages.

conda install ipython numpy scipy netcdf4 matplotlib


Mpiper (talk) 13:05, 3 January 2017 (MST)