anaconda / nb_conda_kernels

Package for managing conda environment-based kernels inside of Jupyter
BSD 3-Clause "New" or "Revised" License
601 stars 70 forks source link

Does not work with TLJH? #217

Closed davidedelvento closed 2 years ago

davidedelvento commented 2 years ago

I have an install of TLJH which creates another conda environment with a yaml file (in addition to base), which I create with sudo /opt/tljh/user/bin/conda env update --file environment.yml. Eventually I'll need to add other environments, but let's stick with two for now.

If I run /opt/tljh/user/bin/conda info --env I correctly see both:

# conda environments:
#
base                  *  /opt/tljh/user
gisandbox                /opt/tljh/user/envs/gisandbox

On JupyterHub, only the base is used. So I installed nb_conda_kernels as follows:

sudo /opt/tljh/user/bin/conda install nb_conda_kernels
sudo /opt/tljh/user/bin/conda install -n gisandbox ipykernel   # since it cannot be in environment.py for other reasons (MyBinder)

And that somewhat works, in that with PATH=/opt/tljh/user/bin/:$PATH python -m nb_conda_kernels list I see

[ListKernelSpecs] WARNING | Config option `kernel_spec_manager_class` not recognized by `ListKernelSpecs`.
[ListKernelSpecs] [nb_conda_kernels] enabled, 2 kernels found
Available kernels:
  conda-env-gisandbox-py    /opt/tljh/user/envs/gisandbox/share/jupyter/kernels/python3
  python3                   /opt/tljh/user/share/jupyter/kernels/python3
  conda-root-py             /opt/tljh/user/share/jupyter/kernels/python3

It is a little strange that a kernel is reported twice, but counted once, and that the names do not match the other ones, but I can live with that.

The problem is that in the browser I don't see see anything indicating this other environment. I'd post a screenshot as requested in other issue reports, but I am not even sure a screenshot of what, since the instructions do not indicate where I should see this option (notebook? hub? lab? where?) -- perhaps you should include a screenshot in the instructions ;-)

If I start a notebook and try to import packages that are included in the custom environment, that fails, so I know it is using base.

davidedelvento commented 2 years ago

It does work. See https://github.com/geospatialcomputing/gisandbox for how I implemented it.