Home / Resources / Guide

Run Python scripts with conda on UN-HPC

Virtual environments on the cluster, plus JupyterLab through an SSH tunnel.

Running python scripts inside virtual environments using conda, also included is an example for running jupyterlab with an SSH tunnel.

Setup miniconda

  • Open a new SSH session and run
module load miniconda
conda init bash
  • After restart terminal, you can see:
(base) [user@granado ~]$

The default conda env is called (base), to list all available envs run: conda env list

Create a new environment and install dependencies

  • Load miniconda and run:
 conda create --name my_env

This new env will be only available for your account - Install dependencies inside the env:

conda install -n my_env numpy 

Run jupyterlab

  • Open a new SSH session as follows:
ssh -L 8082:127.0.0.1:8082 user@201.150.98.56
  • Load miniconda
module load miniconda
  • Activate wrfda env
conda activate wrfda
  • Start jupyterlab server
jupyter-lab --port 8882