We install both version 2 and 3. The normal Python module also includes many common libraries, such as matplotlib, and ipython. For best performance, NumPy and SciPy are provided as a separate module, see SciPy bundle.
Installing local Python modules
pip command, you can install additional python libraries yourself.
You must first choose a existing python module and load it, e.g:
module load foss/2019b Python/3.7.4 SciPy-bundle/2019.10-Python-3.7.4 matplotlib/3.1.1-Python-3.7.4 h5py/2.10.0-Python-3.7.4
It is a good idea to try to use as many python packages from the module tree as possible, since
- You will have to install fewer additional packages.
- They are sometimes much faster then the generic packages you get from
pip install(numpy can be up to 10x faster).
If you need an additional package, you can then install it via
pip install some_library --prefix <your_python_path>
which will skip all the dependencies you already satisfy via the loaded modules.
You will need add the site-packages path to
Similarly, you may have to add
$PATH and for some libraries, also extend
$LD_LIBRARY_PATH to where various shared libraries may end up.
When you are done, you can put something like this in your job-script:
module load foss/2019b Python/3.7.4 SciPy-bundle/2019.10-Python-3.7.4 matplotlib/3.1.1-Python-3.7.4 h5py/2.10.0-Python-3.7.4 export PYTHONPATH=$PYTHONPATH:<your_python_path>/lib/python3.7/site-packages/ python ./my_script.py
virtualenv command is included in the Python module.
The first time, we create a new virtual environment (only done once)
to use this environment, we must activate it (every time you log in)
and then we can install modules locally
pip install some_module
For more information see 1
Please note that when running Matplotlib, you might want to run
after importing, to avoid Matplotlib trying to use the X Windows backend, which will fail if you didn't log in with X forwarding (which won't work in batch jobs).
NOTE The best way to create conda environments is with Singularity. There is an example recipe at
which can be used as e.g.
singularity exec /apps/Singularity/conda-example.simg python my_script.py
This drastically reduces the installation size, and the number of files (down to 1), making it drastically better for the centre storage. Many conda packages aren't build compatible with CentOS6 (or even 7). In these cases, you must use singularity, or build all of them manually. Please see our Singularity page for more details.
If you really can't use containers
If you really can't create a container, you can create conda environments (these become large! Don't try to create them in your home directory), e.g.
module load Anaconda3 cd <somewhere_with_a_lot_of_space> conda create -p my_conda python=3
Activate the environment when you wish to use it:
source activate <somewhere_with_a_lot_of_space>/my_conda
(you might want to create an alias, or do this in your bashrc, as you will need to do this every time you run the program).
Install what you need, you can also add other channels, e.g:
conda config --add channels acellera conda install htmd
conda will cache files in
~/.conda/pkgs/ which are necessary.
These extra copies fill up your disk quota, and you can clear them out with the command:
conda clean --all