Remove environments from the Jupyter Lab Launcher


Hello All, I have several environments that I want to remove from the Launcher in Jupyter Lab. How can I accomplish that? I am accessing Jupyter Lab via Anaconda on Windows. I have the distribution of Anaconda that contains Python 3.7. Thanks in advance!



Can you please define what you mean by environments?



I am referring to conda environments. Conda environment are virtual environments that lets you sandbox Python and packages for a specific situation. There is a lot of information about them on the internet. The environments that I want to remove are in position 2 and 4. The environment in position 2 is actually a regular Python environment and 4 is a conda environment.



These entries correspond to kernelspecs which contain the metadata corresponding to the kernel that is invoked within given notebook or console. One way to manage which kernelspecs are avaible is via a kernelspec whitelist. Another way is to remove the unwanted kernelspecs from your system. Since that may impact others, here’s how to go about the former…

  1. From the same environment in which juptyer lab is invoked, run the following: jupyter kernelspec list
    This will produce a list of kernel and directory names containing kernelspec definitions. What you see in Notebook/Lab are the display name values located in the kernel.json file within each of these directories. However, the whitelist is built using the name from the first column of each of the entries - which essentially corresponds to the lowercased basename of the second column.
  2. Locate the entries you’d like to make available. The first and fifth entries will likely correspond to python3 and ir respectively. Not sure how the name of the third entry will be manifested in the output but you should be able to infer from the directory name of the 3 that remain.
  3. Assuming the third entry is mycondapythonkernel, add it along with the others to your whitelist. This can be done from the command line using --KernelSpecManager.whitelist="['python3','ir','mycondapythonkernel']" or via the configuration file with an entry c.KernelSpecManager.whitelist = set(['python3','ir','mycondapythonkernel']). The order in the list doesn’t affect their display in Lab.
  4. Restart Lab and only the 3 kernelspecs should be displayed.