Jupyter Notebook on Raspberry Pi

Published: May 12, 2020

Writing Python scripts for Raspberry Pi can be even easier. Have you ever run into a problem where a script written on your computer stopped working after you moved it to the Pi? Debugging it is not as straightforward as the method shown below. We will use Jupyter Notebook and set up remote access to it from our Windows computer.

Installation

The installation is very typical. First, let's update the packages

pip3 install --upgrade pip

The update may take a while. Next, install the actual package from the repository:

pip3 install jupyter

Running

To start it, simply enter the command

jupyter notebook

It is worth getting familiar with the basic startup parameters. We do not have to ask it to open a browser, and we can also change the default port the server runs on.

jupyter notebook --no-browser --port=8889

Remote access

The simplest way is to connect to the remote Jupyter instance using the Windows console. Start it on the Raspberry Pi, then open a console on Windows (CMD or PowerShell, it does not matter) and enter:

ssh -N -f -L localhost:8888:localhost:8888 [email protected]

The parameters probably do not need much explanation, as they are fairly straightforward. We specify what we want to forward, where to forward it, and provide the access details. After this step, enter the password and you are done. Thanks to the -f option, the tunnel runs in the background after authentication, so you can close the console window. You can now open the specified address in your browser (localhost:8888 here) and enter the token generated when Jupyter was started.

Comments (0)

No comments yet.

Add a comment

Comments are published after moderation. Your e-mail address stays private.