mamba-org / gator

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

pick non-base environment as kernel for notebooks #150

Closed fcollonval closed 3 years ago

fcollonval commented 3 years ago

I have a (maybe?) related issue. I just set up a new JupyterLab 3 environment and installed gator to manage conda envs (I previously used nb_conda_kernels but it doesn't look like it works anymore?).

The gator tab shows all my existing kernels but I can't start a notebook in anything but the base environment. Is there some additional step I need to take to make them discoverable?

edit: I guess my issue is different and just required ipython kernel install --user --name=<name>. Somehow in the past that wasn't necessary for me to see new kernels.

Originally posted by @jamestwebber in https://github.com/mamba-org/gator/issues/147#issuecomment-864445995

fcollonval commented 3 years ago

You are correct @jamestwebber.

This was not related. nb_conda_kernels is not a dependency of this project (any more - to be precise).

If you are using JupyterLab from an environment, you need to install nb_conda_kernels in that environment too to see the others environment.

jamestwebber commented 3 years ago

If you are using JupyterLab from an environment, you need to install nb_conda_kernels in that environment too to see the others environment.

Am I understanding this right--I need to install nb_conda_kernels in both the jupyter env (that is, the one which I run the server in) as well as the kernel env? That seems strange. In the past, I would just install it in the server env, and then installing ipykernel in another env would make it visible.

But at least for now, using ipython kernel install is easy enough. It was a little more convenient when it could auto-detect new kernels but it's not that critical. What would be much cooler is if I didn't need to install anything in the "kernel" env, but I can't imagine that being simple to implement.

edit: Or perhaps you are just saying I need nb_conda_kernels because I'm running jupyter in an environment. It doesn't appear to be necessary, as long as I register the other kernels.

fcollonval commented 3 years ago

edit: Or perhaps you are just saying I need nb_conda_kernels because I'm running jupyter in an environment.

Yes this is what I meant. So if you are installing and running jupyter from your environment my-second-env, you need to install nb_conda_kernels in my-second-env to see the other environments.

It doesn't appear to be necessary, as long as I register the other kernels.

This actually depends on your settings. When you are installing a kernel explicitly with ipython kernel install, a file is created to tell jupyter about how to start that kernel. Depending on the folder in which that configuration file will be created, you will see or not that kernel in jupyter. You are seeing it because by default the kernel is installed in your user settings.

usage: ipython-kernel-install [-h] [--user] [--name NAME] [--display-name DISPLAY_NAME] [--profile PROFILE]
                              [--prefix PREFIX] [--sys-prefix] [--env ENV VALUE]

Install the IPython kernel spec.

optional arguments:
  -h, --help            show this help message and exit
  --user                Install for the current user instead of system-wide
  --name NAME           Specify a name for the kernelspec. This is needed to have multiple IPython kernels at
                        the same time.
  --display-name DISPLAY_NAME
                        Specify the display name for the kernelspec. This is helpful when you have multiple
                        IPython kernels.
  --profile PROFILE     Specify an IPython profile to load. This can be used to create custom versions of the
                        kernel.
  --prefix PREFIX       Specify an install prefix for the kernelspec. This is needed to install into a non-
                        default location, such as a conda/virtual-env.
  --sys-prefix          Install to Python's sys.prefix. Shorthand for --prefix='/home/fcollonval/miniconda3'.
                        For use in conda/virtual-envs.
  --env ENV VALUE       Set environment variables for the kernel.

nb_conda_kernels on the other hand is loading dynamically the environment as kernel inside of jupyter (without writing files - expect if you use non-default configuration). This is the reason you need to install it in every environment you are running jupyter from.

jamestwebber commented 3 years ago

Thanks for the clarification! I suppose this issue doesn't have much to do with gator but it was useful