mamba-org / gator

Conda environment and package management extension from within Jupyter
Other
260 stars 30 forks source link

Pick Mamba environment as kernel for Jupyter Notebook #187

Closed rgaiacs closed 2 years ago

rgaiacs commented 2 years ago

Description

I have two Mamba environments:

$ mamba env list
# conda environments:
#
base                     /home/raniere/mambaforge
jupyter               *  /home/raniere/mambaforge/envs/jupyter

I'm running Jupyter Lab (with gator installed) from the jupyter environment (to avoid dependency issues with base). I created a new Mamba environment called first-carpal using gator from Jupyter Lab.

envs

In a Jupyter Notebook, I only have the Python 3 kernel (from jupyter env) listed:

kernels

How do I add the new first-carpal env as a Python kernel?

Reproduce

  1. From the menu bar, go to Settings > Conda Packages Manager.
  2. Click on 'Create'.
  3. Type first-carpal in the field Name.
  4. Click on 'OK'.

Expected behavior

first-carpal is a valid Python kernel.

Context

# packages in environment at /home/raniere/mambaforge/envs/jupyter:
#
# Name                    Version                   Build  Channel
mamba_gator               5.1.2              pyhd8ed1ab_0    conda-forge
JupyterLab v3.3.3
/home/raniere/mambaforge/envs/jupyter/share/jupyter/labextensions
        jupyterlab-jupytext v1.3.8+dev enabled OK (python, jupytext)
        jupyterlab_pygments v0.2.1 enabled OK (python, jupyterlab_pygments)
        @mamba-org/gator-lab v3.0.2 enabled OK (python, mamba_gator)
        @jupyter-widgets/jupyterlab-manager v3.1.0 enabled OK (python, jupyterlab_widgets)

Other labextensions (built into JupyterLab)
   app dir: /home/raniere/mambaforge/envs/jupyter/share/jupyter/lab
     active environment : jupyter
    active env location : /home/raniere/mambaforge/envs/jupyter
            shell level : 3
       user config file : /home/raniere/.condarc
 populated config files : /home/raniere/mambaforge/.condarc
                          /home/raniere/.condarc
          conda version : 4.12.0
    conda-build version : not installed
         python version : 3.9.10.final.0
       virtual packages : __linux=5.13.0=0
                          __glibc=2.34=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/raniere/mambaforge  (writable)
      conda av data dir : /home/raniere/mambaforge/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://conda.anaconda.org/nvidia/linux-64
                          https://conda.anaconda.org/nvidia/noarch
                          https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/raniere/mambaforge/pkgs
                          /home/raniere/.conda/pkgs
       envs directories : /home/raniere/mambaforge/envs
                          /home/raniere/.conda/envs
               platform : linux-64
             user-agent : conda/4.12.0 requests/2.27.1 CPython/3.9.10 Linux/5.13.0-40-generic ubuntu/21.10 glibc/2.34
                UID:GID : 1001:1001
             netrc file : None
           offline mode : False
fcollonval commented 2 years ago

Hey @rgaiacs you can install nb_conda_kernels in the same environment as JupyterLab to dynamically create kernels for conda environments.

rgaiacs commented 2 years ago

@fcollonval Thanks for the reply. I installed nb_conda_kernels and it resolved the issue. Why nb_conda_kernels isn't a dependency for gator?

fcollonval commented 2 years ago

Why nb_conda_kernels isn't a dependency for gator?

We don't need it from a code point of view; and we will not enforce it as it may not play nicely in some configuration or with other jupyter tools like voila or nbconvert.