Search code examples
pythonjupyter-notebookcondaminiconda

How to remove inactivate conda environment names from jupyter notebook?


I have created multiple miniconda environments in my macbook. But when I open jupyter notebook, it shows non-existent conda environments I created long ago and which are no longer available in conda environments.

How to remove these non-existing environment names from jupyter notebook?

My current conda list

enter image description here

What Jupyter Shows

(NOTE: For example, Jupyter notebook shows environment "xx" which is not in conda env list)

enter image description here

How to remove non-existent environments

How to remove non existing environment such as "xx" from showing up when I open jupyter notebook?


Solution

  • It depends on how you registered the kernel, but I suspect you used the python -m ipykernel install --user. In that case, you should be able to get a list of where the kernels are registered with

    jupyter kernelspec list
    

    and you can simply delete the folders corresponding to kernels you wish to delete.

    It may be worth noting that using nb_conda_kernels to auto-register all Conda envs with ipykernel would automatically remove kernels when you delete their environments or remove the ipykernel from the environment.