For those wishing to use Python on the CBS server, below are instructions for setting up a general purpose virtual environment.
-
Set up a virtual environment. (current available python versions: 3.7, 3.8, and 3.9)
python3.9 -m venv ~/venv
-
Activate it.
source ~/venv/bin/activate
-
Upgrade pip and install any packages you need.
pip install --upgrade pip
pip install numpy scipy pandas nilearn nibabel jupyterlab
-
Start using python, e.g., launch jupyter-lab.
jupyter-lab
-
When finished, deactivate the virtual environment.
deactivate
Note 1: You will always need to activate the virtual environment before using it (e.g., run step 2).
Note 2: virtualenv
(venv) is preferred over conda
on the CBS server, as it more lightweight. Users have also reported strange behavior when using conda.
Note 3: If you want or need to start fresh, simply remove the venv
folder from your home directory.
Note 4: It is recommended to keep separate virtual environments for softwares that may have conflicting dependencies. To create a new virtual environment, simply re-run the steps, specifying a new name for the virtual environment folder (e.g., python3.9 -m venv ~/new_venv
).