Windows: Essential Jupyter Notebooks setup with pip and pipenv

In this post I will show you how to setup jupyter notebooks with pip under Windows. Also we will go through the process of creating virtual environments with pipenv and adding them to the kernel list in jupyter.

Python 3

We first have to install python. Since python 2 is essentially deprecated we will go with python 3 instead. Whenever we call a command with python in the following we mean python3. Visit https://www.python.org/ and download the latest, stable version of python 3. Be sure to check that you do not choose to add python to your PATH variable as this could interfere with other installations like Cygwin. Once the installation is finished create two directories in your documents folder:

where in both files you should replace C:\Python3 with the base path of your python installation. The first file will start a command prompt inside your PythonScripts folder and add the python interpreter to your PATH variable. The second file can start jupyter once it is installed. Additionally, you can add links to these files to your python start menu folder.

Jupyter Notebooks

We first make sure that we have a clean package environment. Start pythoncmd.bat and run

pip freeze

If the output is empty you are good to go. If not run the following commands:

pip freeze > req.txtpip uninstall -y -r req.txtdel req.txt

This will uninstall any previously installed packages. To install jupyter simply run

pip install jupyter --upgrade

That’s it! You can now use jupyternotebooks.bat and start coding.

Virtual Environments with pipenv

Virtual environments give you a clean python setup. You create a virtual environment with pipenv by typing

pipenv install

You can use any ordinary pip command with pipenv. In order to add the current virtual environment to your jupyter kernels run