Chapter 3 Setup a Jupyterhub on your RaspberryPi
This chapter is based on the Setup-Guide by Gerold Busch. The following steps must be followed in chronological order to ensure that the JupyterHub works properly:
- Prepare Python Environment
- Install JupyterHub
- Configure JupyterHub as a system service
Note
It is recommended to change the default password and the default user name when setting up the RaspberryPi for the first time. If there are several RaspberryPis in the network, the hostname should also be changed to simplify a later connection via ssh. The hostname is important to address the Pi if the network assigns dynamic IP addresses.
3.1 Prepare Python environment
Redirect the system to python3:
Install the python package manager pip:
3.2 Install JupyterHub
Install the proxy to routes the user requests to the hub and the notebook server:
Install JupyterHub and Jupyter Notebook system-wide:
Create a JupyterHub configuration file:
In order to make changes at the Jupyterhub application, modify the /root/jupyterhub_config.py
-File.
E.g. to change the port on which the JupyterHub runs, uncomment and modify the following line of the config file:
3.3 Configure JupyterHub as a system service
To register JupyterHub as a system service, create the file /lib/systemd/system/jupyterhub.service
and
fill it with:
[Unit]
Description=JupyterHub Service
After=multi-user.target
[Service]
User=root
ExecStart=/usr/local/bin/jupyterhub --config=/root/jupyterhub_config.py
Restart=on-failure
[Install]
WantedBy=multi-user.target
Make sure that the line starting with ExecStart
contains the correct location of the JupyterHub binary and
the config-file.
Afterwards, run the following commands:
sudo systemctl daemon-reload
sudo systemctl start jupyterhub
sudo systemctl enable jupyterhub
sudo systemctl status jupyterhub.service
Now the JupytherHub should be accessible under the link:
http://<address of your raspi/hostname>:8888
Note
This chapter did not include the data transfer to the RaspberryPi. It is recommended to clone the repository on the RaspberryPi or to copy the local files between the computer and the Pi via scp command or VNC.