Skip to content

Instantly share code, notes, and snippets.

@chidimo
Last active September 24, 2019 10:33
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 chidimo/fa24e4172649e99eb1912c921117c7f6 to your computer and use it in GitHub Desktop.
Save chidimo/fa24e4172649e99eb1912c921117c7f6 to your computer and use it in GitHub Desktop.
How to create a custom ipython, aka jupyter notebook kernel with a python virtual environment

Creating a custom ipython or jupyte notebook kernel

  1. Create a python virtual environment using either pipenv or virtualenv

  2. Open up cmd.exe, activate the virtual environment and issue the following to commands

    pipenv install jupyter

    pipenv install ipykernel

  3. To create the custom ipython kernel, issue the following commands

    python -m ipykernel install --user --name other-env --display-name "whatever name you want to give the kernel"

    python -m ipykernel install --user --display-name "whatever name you want to give the kernel"

  4. The --name other-env argument, value pair is optional. See here for explanation

  5. Now when you reload your ipython/jupyter notebooks you should see the newly created kernel listed under kernels. You can see some kernels I've created in the screenshot below.

@AleksDominik
Copy link

So, If I have created this second kernel, how could i link the package that i installed with my pipenv with this kernel? I mean install package for notebook like pandas and some with pipenv?

@chidimo
Copy link
Author

chidimo commented Sep 24, 2019

Hey man.
You simply activate the said environment on your command line and use pip install <package-name> (if you created the environment with virtualenv or pipenv you do pipenv install <package-name> (if you created it with pipenv).
The package should now be available for import inside your notebook.

@AleksDominik
Copy link

al right it's fine for me.

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