There are multiple versions of Python installed on Spartan, which you can check using module spider Python.

Common packages like numpy are already installed with some versions, but may be missing from others.

  • If a Python package is missing, we recommend that you install additional packages locally using pip install into a virtualenv on the login node.


[scrosby@spartan-login1 ~]$ module load GCCcore/11.3.0; module load Python/3.10.4

Virtualenvs allow you to separate Python workspaces, allowing you to have different workspaces for different purposes. This is the recommended way of installing Python modules.

[scrosby@spartan-login2 ~]$ virtualenv ~/venvs/venv-3.10.4
created virtual environment in 3721ms
  creator CPython3Posix(dest=/home/scrosby/venvs/venv-3.8.6, clear=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/scrosby/.local/share/virtualenv)
  added seed packages: pip==20.2.3, setuptools==50.3.0, wheel==0.35.1
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

[scrosby@spartan-login2 ~]$ source ~/venvs/venv-3.10.4/bin/activate
(venv-3.10.4) [scrosby@spartan-login2 ~]$ 

Note you only have to install the package once. You don't need to do it every time you want to use the package.

(venv-3.10.4) [scrosby@spartan-login1 ~]$ pip install matplotlib
Collecting matplotlib
  Downloading matplotlib-3.5.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (11.3 MB)
     |████████████████████████████████| 11.3 MB 29.3 MB/s 

This works well for pure-python packages, but you may encounter errors for those that link to other binary packages. Alternatively, let us know, we can install it for you.

Detailed instructions are available at /apps/examples/Python/ on Spartan.