Table of contents
Open Table of contents
In this short how-to I will install Jupyter within a virtualenv running on Python 3.
- I am running macOS 10.10+. At the time of writing, I am running
macOS Sierra 10.12.2.
- I have Python 3.6 installed. At the time of writing, I am running
pip 9.0.1installed with Homebrew.
- The installation has been tested also on
Windows 10 Pro, with
Python 3.6.1installed from https://www.python.org/.
Create new virtualenv and install Jupyter
This can be done in multiple ways, I use my own handy tool to create a new project with virtualenv.
Now, that I have a new project set up, virtualenv active, and pip & setuptools upgraded to latest versions, I can move forward and install Jupyter and kernel.
pip install jupyter python -m ipykernel install --user
With the installation complete, I can start the server with
jupyter-notebook. This will open my default browser at
http://localhost:8888/. Now I can create my first Jupyter notebook and start data developing.
Install Python packages
The environment is no good with no packages. I can install them the usual way by stopping the Jupyter server and installing them from command line. The other way is to install packages directly from Jupyter notebook by running this in a code cell (the ! enables the running of shell commands):
!pip install pandas
Now I have pandas installed within my virtualenv and I can inport the module within the workbook:
import pandas as pd
It’s important to manage the dependencies as always, so do not forget to build the requirements.txt with
pip freeze >requirements.txt.
And that’s pretty much all there is to it. Happy Jupytering.