A guide to installing and setting up a Jupyter notebook server with Python 2.7 and 3 kernels for a local network in RHEL 7/Centos7/Oracle Linux 7.

First install the required dependencies for Jupyter notebook.

Install dependencies and repositories:

Update: the following repos are not functional.

sudo yum install epel-release
yum install -y python-pip python-devel python-virtualenv
yum groupinstall 'Development Tools'

Set the virtual environment and install Jupyter Notebook using pip.

virtualenv jupyter-virtualenv
source jupyter-virtualenv/bin/activate
pip install jupyter

Run Jupyter notebook and test the installation is working properly on your PC/Workstation.

jupyter notebook

Generate the configuration file for the Jupyter notebook. The configuration file will be different for all the users in the machine to avoid conflict. Generating different configuration file will let all the users in a machine run separate instances of notebook server with user-specified passwords.

jupyter notebook --generate-config

Before starting the notebook server setup a password for your instance using the following command.

jupyter notebook password

If you don’t set up a password the default password will be the access token and can be found in the terminal. (?token=)

Jupyter token

Once the previous steps are done edit the notebook configuration file generated using – generate-config option. The configuration file will be located in the following path.

cat ~/.jupyter/jupyter_notebook_config.py

Use your favorite text editor to open the file and make following changes to make it accessible in LAN. Set IP to ‘*’ to bind on all networking interfaces of the machine. Also, you can use only a public IP address if your machine has one.

c.NotebookApp.ip = '*'

If you want to setup a password manually change the fllowing parameter.

c.NotebookApp.password = u'sha1:bcd259ccf...'

Code to generate a hashed password:

In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

Launching a browser is not necessary when you are running a server.

c.NotebookApp.open_browser = False

Change the port for notebook server to avoid conflict with other applications, by default it will be 8888. If multiple users running notebook server use a different port in each case.

c.NotebookApp.port = 8888 #Change if something already assigned to any other service.

Add the port to firewall and reload.

sudo firewall-cmd --zone=public --add-port=8888/tcp --permanent
sudo firewall-cmd --reload
firewall-cmd --list-all

After configuration enables Jupyter notebook run in the background with nohup().

nohup jupyter notebook &

To stop the server kill the processes.

lsof nohup.out
kill -9

When your system Python version is 2.7 but also want to add Python 3 to the Jupyter notebook, the following code will help.

Enabling Python 2 kernel

python2 -m pip install ipykernel
python2 -m ipykernel install --user

Enabling Python 3 kernel

python3 -m pip install ipykernel
python3 -m ipykernel install --user