Skip to content

How to work in Jupyter Lab

Felix Victor Münch edited this page Apr 1, 2021 · 11 revisions

Install/uninstall virtual environments created with pipenv

While it is possible to simply install and run jupyter-lab within a virtualenv, it is maybe not desirable to install the whole jupyter-lab package for every single project environment. A more elegant solution is to install a so-called 'kernelspec' that points your system-level Jupyter with information about where your virtualenv lives, respectively.

Assumes that Jupyter-Lab is installed on your system (outside a virtual env).

  • enter virtual env with pipenv shell
  • pipenv install ipykernel or pipenv install --dev ipykernel if end users don't need to use Jupyter.
  • python -m ipykernel install --user --name=YOUR_RECOGNIZABLE_NAME_FOR_THIS_ENV

Now you should be able to start jupyter-lab on your system (outside the virtual env) and the launcher will offer you to start a notebook using this virtualenv.

If you delete the project virtualenv for whatever reason and want to keep your kernel-list in Jupyter clean, you can list all kernels Jupyter knows of

jupyter kernelspec list

and then remove the respective kernel specifications with

jupyter kernelspec uninstall YOUR_RECOGNIZABLE_NAME_FOR_THIS_ENV

Source:https://janakiev.com/blog/jupyter-virtual-envs/

Clone this wiki locally