Skip to content

Instantly share code, notes, and snippets.

@glw
Last active November 2, 2021 04:03
Show Gist options
  • Save glw/adf52ec46f8922400fc6ae2f67bc66c4 to your computer and use it in GitHub Desktop.
Save glw/adf52ec46f8922400fc6ae2f67bc66c4 to your computer and use it in GitHub Desktop.
Jupyter Notebooks in Virtual Environments

source: https://towardsdatascience.com/jupyter-notebooks-i-getting-started-with-jupyter-notebooks-f529449797d2

This way of installing Jupyter Lab allows you to install it once and any virtual env has access to Jupyter through ipykernel.

  1. Install pyenv (w/ virtualenv)
  2. Install a new version of python pyenv install <a new python version>
  3. Set a global version of python pyenv global <new python version>
  4. Install pipx

Once the above are installaed.

  1. Install Jupyter Lab using pipx. Pipx should be using pyenv's python global python version. (which pipx to check).
  2. Create a virtual env pyenv virtualenv <python version> <name of venv>
  3. Activate virtual env pyenv activate <name of venv>

Inside your virtual env

  1. pip install ipykernel
  2. python -m ipykernel install --user --name <name of venv> --display-name "Python (<name of venv>)"

Successul output will look like: Installed kernelspec geopy39 in /home/username/.local/share/jupyter/kernels/geopy39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment