Create Python environment with Pipenv and Jupyter

Pipenv is excellent for Python development and Jupyter is great for data science. I want to share how I set Pipenv and Jupyter for my project.

Create Python environment

pipenv --python 3.7

or

pipenv --three

Of course you can use different argument to create the environment of python 2 or other versions of Python

Install necessary package

pipenv install ipykernel

Activate shell and create Jupyter kernell

pipenv shell
python -m ipykernel install --user --name=<kernel-name>

Switch to the pipenv kernel

Launch Jupyter notebook

The new kernel will be shown in the menu

jupyter notebook

jupyter

Install other packages

You can install other python packages that would be available in this kernel.

e.g.

pipenv install pandas

Change kernel name

Get kernel list

jupyter kernelspec list

You can get a list showing each kernel’s path.

Edited the json file in the directory of kernel you want to rename.

Change the value of display_name and this kernel will be renamed.

Restart Jupyter notebook and Jupyter is supposed to show the new name of the same kernel.

Delete kernel

jupyter kernelspec uninstall <kernel-name>