Skip to content

Instantly share code, notes, and snippets.

@satwikkansal
Created September 19, 2019 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satwikkansal/a87ffbe4e251a2cae7081c5809fcbc06 to your computer and use it in GitHub Desktop.
Save satwikkansal/a87ffbe4e251a2cae7081c5809fcbc06 to your computer and use it in GitHub Desktop.
Steps for settting up Jupyter notebook for virtual environment in Python (2019 guide)

Make sure you have jupyter installed and virtual envrionment set up already. I prefer virtualenv. If you don't have it set up, you can follow these steps,

$ pip install jupyter
$ pip install virtualenv
$ python -m virtualenv venv
$ source venv/bin/activate

Here, we've created virtual environment called venv and activated it.

Now, let's install kernel specific to your virtual environment that you'll be able to use in your notebook.

$ pip install ipykernel
$ python -m ipykernel install --user --name=some_cool_project_name

Now you can launch the jupyter notebook (from a different terminal) and select the kernel by going to Kernel > Change Kernel > some_cool_project_name via the menu.

Note I've installed the jupyter outside the virtual environment, but if you choose to install it inside, then you'll have to launch jupyter from inside the virtual environment instead of open a different terminal.

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