Using Virtual Environments and Jupyter Notebooks in OnDemand
This information is part of a collection of information on constructing and using virtual environments.
The information below applies to virtual environments made with Miniforge (i.e., conda virtual environments, CVEs) and to VEs made with pip-venv (the links to both methods are on this page: constructing and using virtual environments.
Follow these steps to use your VE in a Jupyter Notebook interactive session on OnDemand:
Check for
ipykernel
installation. Ensure thatipykernel
is installed in your environment. After activating your environment, you can run thepip freeze
command to list all the installed libraries. Ifipykernel
is not listed, you can install it with thepip install ipykernel
command.Set up the environment ‘Kernel’. Assuming your environment is named
my_env
, activate it and run the following command:
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
This will create a Jupyter Kernel named “Python (my_env),” which allows you to use ‘my_env’ within your notebooks.
Launch and select the Kernel in Jupyter Notebook. After launching Jupyter Notebook on OnDemand (refer to the video tutorial here), open your notebook, then go to ‘Kernel’ in the top menu bar, select ‘Change Kernel’, and choose ‘Python (my_env)’ kernel.