ligo-ex ligo-ds
  Richardson Lab Data Science Log  Not logged in ELOG logo
Message ID: 1     Entry time: Tue Feb 1 17:02:46 2022
Author: Rutuja 
Type: Update 
Category: ELOG 
Subject: JupyterHub Setup: Users unable to use their conda environments in jupyter notebooks 

Issue: Currently, the only kernelspec present in /usr/local/share/jupyter/kernels is the miniconda environment called 'python' (/opt/miniconda3/envs/python/).

Goal: We want users to be able to create their own conda environs and use them in their jupyter notebooks. Currently they can only use their custom environs in terminal.

ToDo: Figure out a way to place user1's custom environment 'mytestenv' kernelspec in /home/user1/.local/share/jupyter/kernels/mytestenv


[UPDATE] Fixed this issue. Users should follow the following steps to have their custom conda environs available in their jupyter notebooks.

1. Say you have a conda env named mytestenv. Activate this env.

2. Install ipykernel in the conda env you want to add to Jupyter:

$ conda install ipykernel

3. Install the kernel

$ python -m ipykernel install --user --name mytestenv --display-name "My Test Env"

You can always change the --name (how this kernel appears in your jupyter directory) and --display-name (how it appears in the JupyterLab's 'Select Kernel' window) but it is recommended to match it with your conda environment name to avoid future confusion.

4. Check if you installed the kernel successfully:

$ jupyter kernelspec list


[UPDATE: JR] After completing step 4, you must restart your server for the newly installed environment to be visible in your Jupyter notebooks.

5. Click: File > Hub Control Panel > Stop My Server > Start My Server

6. Reopen your notebook. Then click: Kernel > Change Kernel... and select the name of your custom conda environment from the drop-down list.

ELOG V3.1.3-7933898