Jupyter Notebooks on OODHPC provides access to Jupyter notebooks on all three clusters through our Open OnDemand interface. For more information on using this service, see our page on Open On Demand. Custom KernelsTo use locally-installed packages in your Jupyter session, you can create a virtual environment and install your own kernel. The default version of Python available in Jupyter is 3.8.2. If you would like to create a virtual environment using a standard python module, you will need to use the default version that Jupyter uses. If you want to use your own version of python, you can use an Anaconda environment. Steps for both options are provided below: Using a Python ModuleIn a terminal session, start by logging into an interactive session since modules are not available on the login nodes. Once you're ready to go, load the python version 3.8.2 and create your virtual environment: Code Block |
---|
| module load python/3.8/3.8.2 # Customize these commands to fit your needs
python3 -m venv --system-site-packages ~/py38-env # See the section on virtual environments above for more info
source ~/py38-env/bin/activate # activate your environment |
Once your environment is ready to go, pip-install jupyter and create your own custom kernel. The --force-reinstall flag will allow you to install the jupyter package in your local environment and will not affect the system version. This will create a directory in ~/ .local/share/jupyter/kernels/ in your account: Code Block |
---|
| pip install jupyter --force-reinstall
ipython kernel install --name py38-env --user
pip install emoji # example python package for demonstration purposes |
Now, go to https://ood.hpc.arizona.edu/ and start a Jupyter notebook. Once the session starts, open it and click the "new" dropdown menu in the upper right. If everything is working correctly, you should see your custom name:  Once you've selected your environment, try loading a custom module to check that everything is working as expected: 
Using AnacondaIn a terminal session, start by logging into an interactive session, then load your preferred anaconda module, initialize and activate it in your account, and create your local environment: Code Block |
---|
| module load anaconda/<version> # replace <version> with the version you'd like to use
conda init bash # only needed if using conda for the first time
source ~/.bashrc && conda activate # make conda initialization live
conda create --name py38 python=3.8 # create a local environment with your preferred python version. Name and version are customizable.
conda activate py38 # activate your new local environment |
Next, you'll pip install jupyter and use that to create your own custom kernel. This will create a file saved to ~/ .local/share/jupyter/kernels/ in your account:
Code Block |
---|
| pip install jupyter
ipython kernel install --name py38 --user
pip install emoji # example python package for demonstration purposes |
Next, go to https://ood.hpc.arizona.edu/ and start a Jupyter notebook. Once the session starts, open it and click the "new" dropdown menu in the upper right. If everything is working correctly, you should see your custom name: 
Once you've selected your environment, try checking the python version in your notebook using the sys module. Additionally, for demonstration purposes, we'll check that the package we installed can be imported and is working. 
|