anaconda/nb_conda_kernels

Kernel discovering not locating python kernels

Closed this issue · 1 comments

I have a "main" jupyter environment py3.8, and a secondary environment rap_env. I would like to use nb_conda_kernels to access the environment of the second within a jupyterlab server from the first.

I've installed nb_conda_kernels==2.3.1 on the first notebook, and ipykernel on both environments per the installation instructions, additionally running:

python -m ipykernel install --user --name env_name --display-name "env_name-k"

Checking jupyter kernelspec list shows all the kernels:

(py3.8) [ci411@cm23 ~]$ jupyter kernelspec list
Available kernels:
  conda-root-py    /home/ci411/.local/share/jupyter/kernels/conda-root-py
  py3.8-k          /home/ci411/.local/share/jupyter/kernels/py3.8-k
  python3          /home/ci411/.local/share/jupyter/kernels/python3
  rap_env-k        /home/ci411/.local/share/jupyter/kernels/rap_env-k

However using nb_conda_kernels list does not:

(py3.8) [ci411@cm23 ~]$ python -m nb_conda_kernels list
[ListKernelSpecs] Removing existing kernelspec in /home/ci411/.local/share/jupyter/kernels/conda-root-py
[ListKernelSpecs] Installed kernelspec conda-root-py in /home/ci411/.local/share/jupyter/kernels/conda-root-py
[ListKernelSpecs] [nb_conda_kernels] enabled, 1 kernels found
Available kernels:
  conda-root-py    /share/apps/anaconda3/2020.07/share/jupyter/kernels/python3

My configuration is as follows:

(py3.8) [ci411@cm23 ~]$ python -m nb_conda_kernels.install --status --verbose
Determining the status of nb_conda_kernels...
CONDA_PREFIX: /scratch/ci411/.conda/envs/py3.8
Entry points:
  - conda = nb_conda_kernels.discovery:CondaKernelProvider
  NOTE: entry points not used in Jupyter 6.1.7
Configuration files:
  - /etc/jupyter: <no files>
  - /usr/local/etc/jupyter: <no files>
  * $CONDA_PREFIX/etc/jupyter: 
      jupyter_config.json: {
          "NotebookApp": {
            "kernel_spec_manager_class": "nb_conda_kernels.CondaKernelSpecManager"
          }
        }
      jupyter_notebook_config.json: {
          "NotebookApp": {
            "nbserver_extensions": {
              "nb_conda": true
            }
          }
        }
  - ~/.jupyter: 
      jupyter_config.json: {
          "CondaKernelSpecManager": {
            "kernelspec_path": "--user"
          }
        }
      jupyter_notebook_config.json: {
          "NotebookApp": {
            "password": "sha1:e4e8c97497ff:e7a7087290cde39f76f4cfdffb35afae14df46eb"
          }
        }
Status: enabled

I can see the kernels listed from jupyter kernelspec list in my notebooks, but they seem to point to the host environments packages, defeating the purpose of switching. What am I missing in the setup of my environment that will allow me to switch between conda environments in jupyter? Thanks for your help.

Exporting both environments to yaml files and rebuilding them seems to have fixed the issue, although I'm unsure as to the cause/solution.