Create a Jupyter Virtual Environment

From UCSC Genomics Institute Computing Infrastructure Information

Revision as of 17:33, 22 May 2026 by Weiler (talk | contribs) (Created page with "__TOC__ If you need a specific Jupyter environment, because maybe you need specific Python modules or something like that, you've come to the right place. == Find a Location to Install == You will want to install your Jupyter Virtual Environment somewhere accessible from the PRISM Compute Nodes and all the cluster nodes, so it will need to either be in your home directory or in '''/private/groups/[lab_name]''' somewhere. For this example I'll use my home directory, '...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

If you need a specific Jupyter environment, because maybe you need specific Python modules or something like that, you've come to the right place.

Find a Location to Install

You will want to install your Jupyter Virtual Environment somewhere accessible from the PRISM Compute Nodes and all the cluster nodes, so it will need to either be in your home directory or in /private/groups/[lab_name] somewhere. For this example I'll use my home directory, /private/home/weiler.

Create Your Virtual Environment

I'll be creating this Virtual Environment in my home directory (but create it wherever you deem necessary). So:

cd /private/home/weiler

Then create the directory for the environment to go in:

mkdir jupyter_venv

Next create the environment!

cd jupyterhub_venv
python3 -m venv jupyterhub

It will create an environment in /private/home/weiler/jupyter_env/jupyterhub.

Next we activate the environment:

source ~/jupyter_env/jupyterhub/bin/activate

Your prompt should now look something like this:

(jupyterhub) [weiler@mustard jupyter_venv]#

Install Requisite and Optional Packages

From there you will need to minimally install these three packages:

(jupyterhub) [weiler@mustard jupyter_venv]# pip3 install jupyterhub jupyterlab batchspawner

You will need those three packages to start. So definitely install those. You can additionally install any other python packages, such as:

(jupyterhub) [weiler@mustard jupyter_venv]# pip3 install numpy pandas

Exit Your Virtual Environment

To exit out of your virtual environment, simply do:

deactivate

and you should return to your regular shell.

Call Your Virtual Environment In JupyterHub

Once you login to JupyterHub on the cluster here:

https://jupyterhub.prism

You will want to click on the Advanced tab at the top. When defining your notebook resources, under "Jupyter environment", select "Custom". Then define your description and give the path to your /bin directory in your environment, as such:

File:Custom2.png
Custom Environment

It will then launch a notebook based on that environment, and all modules and packages installed in that environment will be available.