Skip to content

Instantly share code, notes, and snippets.

@MilesDowe
Last active August 18, 2022 20:46
Show Gist options
  • Save MilesDowe/00bc379298f7e639af38b6cc0631afdc to your computer and use it in GitHub Desktop.
Save MilesDowe/00bc379298f7e639af38b6cc0631afdc to your computer and use it in GitHub Desktop.
A way to specify a pipenv environment while in a running Jupyter Lab/Notebook/Hub instance.

Steps grabbed from: https://stackoverflow.com/a/47296960

Adding a kernel based on your venv

Inside of your target venv workspace:

pipenv install ipykernel
pipenv run python -m ipykernel install --user --name=<name-of-pipenv-venv>

Make the name value something that describes your current workspace. Can just be the directory/venv name.

Open a notebook and then select your new kernel.

Removing unwanted kernels

Run the following (doesn't need your venv to be active):

jupyter kernelspec uninstall unwanted-kernel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment