Skip to content

Instantly share code, notes, and snippets.

@HarvsG
Last active March 9, 2021 13:08
Show Gist options
  • Save HarvsG/49447b15324950860fd695606cc3f409 to your computer and use it in GitHub Desktop.
Save HarvsG/49447b15324950860fd695606cc3f409 to your computer and use it in GitHub Desktop.

How to create a new env for a jupyter workspce

  1. Ensure that the requirement for working with envs are installed sudo apt install python3-venv

  2. Work out the python version you want to work with python --version or python3 --version or which python

  3. Once you have chosen the python version cd to the directory you want the env to be stored in

  4. run /path/to/my/python3 -m venv nameOfEnv of course this may just be python not python3

    • in my case /usr/bin/python3
  5. Then activate the env with source nameOfEnv/bin/activate

  6. Install the IPython Kernel (nameOfEnv)$ pip install ipykernel

  7. Install the env to jupyter notebook (nameOfEnv)$ python -m ipykernel install --user --name nameOfEnv --display-name "Python3.x (nameOf)"

  8. When inside the env use pip install package_name and not other variations

  9. if it exists then pip install -r requirements.txt

Ta-da

It should now appear as kernel in the jupyter lab interface

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