Python is one of the most used interpreted languages for data analysis, competing directly with long-established commercial packages like Matlab or IDL.
Different versions of the OS come with different versions of python.
The most popular are
All of these should be available by default on our systems (though see our notes below on how to install newer versions for yourself if wanted).
A wide variety of Astronomy-related python packages are installed as part of Ureka
You might find that some python packages you need are not available pre-packaged for our linux distribution, or the available version might be too old. There are a couple of ways you can handle this - first here is the simplest, installing the modules within your home directory (then read about “virtualenv” below for a cleaner solution).
To install a python module in your user space, download the tarball, unzip it, cd into the directory and run:
python setup.py install --prefix=/path/to/your/place
The installer will create a subdirectory named
lib64 under the directory above. These
lib* dirs will have a directory named
python2.6 (for example), and those will have a subdirectory named
site-packages. Add all paths to these
site-packages subdirectories in your
PYTHONPATH environment variable. Some packages may also create a
bin directory that needs to be added to
The virtualenv kit provides the ability to create virtual Python environments that do not interfere with either each other, or the main Python installation. If you install virtualenv before you begin coding then you can get into the habit of using it to create completely clean Python environments for each project. virtualenv should be installed on all SL6 Linux machines.
To create a new virtual environment (named “py_phys” in this example), run
This will create a directory named py_phys in the current working directory. You can also specify a full path, e.g.
To activate the new environment, use
Once in the new environment, you can add packages using the
pip command, eg:
pip install packageName
Often a set of software will be used by an entire group rather than just one individual. We can set up specific areas for you to manage shared software, rather than within a home directory.