Python
Using Python virtual environments with uv
For Python specifically, you can set up a virtual environment, which acts similarly to a personal module but for using Python packages. In these virtual environments, you can install whichever Python packages you want, as well as manage different python versions. We prefer you to use uv for your virtual environments over venv, as its easier on storage limits and backup requirements.
$ module load python # (1)!
$ module load uv
$ uv init <project directory> # (2)!
$ uv add <my-python-package> # (3)!
$ uv run <script>.py # (4)!
- This will load the cluster default python version. If you need a specific
version, you can instead use
module load python/3.12.4. - This creates a new project managed by uv. If you have a prexisting project directory, this command will let uv track it.
- If a virtual environment doesn't already exist, uv will create one named .venv and install packages here! (If you have a venv already, check uv's documentation for letting uv recognize it)
- With uv, you don't need to activate a virtual environment if it is named .venv, you can simply run your code!
Using Python virtual environments with conda
A similar process can be used with miniconda to create and activate a conda environment. Again, we prefer you to use uv, but there are some cases where you must use a conda environment.
$ module load miniconda3
$ conda create --name <my-env>
$ conda init bash # (1)!
$ source activate <my-env> # (2)!
$ conda install <my-python-package>
- Note that this modifies your .bashrc so that every time you log in conda will be sourced as your python distribution.
- run
conda deactivateto exit your conda environment.
For more information, you can look at the conda env documentation
Jupyter Notebooks vs. .py Files
We recommend using Jupyter notebooks for exploration and data visualization. Notebooks provide an interactive environment that’s ideal for experimenting and analyzing data. For larger scripts or batch jobs, .py files are often a better fit, as they are easier to run on compute nodes in non-interactive sessions.
Running Jupyter Notebooks on a Compute Node
If you'd like to run a Jupyter notebook on a compute node, you can do so using the sjupyter command. This requires an active virtual environment that includes Jupyter:
Running Jupyter via Open OnDemand
If you are unfamiliar with the terminal and just want to use Turing resources with Jupyter, you can use the interactive app provided by Open Ondemand.
Other Jupyter Kernals
jupyter also supports matlab and maple kernels.
Matlab - install instructions
Maple - install instructions
R - install instructions Note, this also requires an older version of jupyter, and npm. So before following these instructions run
and create a virtual envionment with jupyter 3uv add jupyterlab==3.*
This allows you to access compute resources within a notebook environment for more intensive interactive work.