Jupyter on Lawrence

Installing Jupyter

Request a node:

[email protected] ~]$ srun --pty bash

Make a directory for Jupyter scripts and cd into it.

[email protected] ~]$ mkdir jupyterScripts
[email protected] ~]$ cd jupyterScripts
[email protected] jupyterScripts]$

Copy the installation and starting scripts into your directory.

[email protected] jupyterScripts]$ cp /apps/jupyter-notebook/* ./
[email protected] jupyterScripts]$ ls
install-jupyter-notebook.sh start-jupyter-notebook.sh
[email protected] jupyterScripts]$

Run the install script.

Note: If you would like to add kernels to your Jupyter Notebook (e.g. R, widgets, etc.), add the "-h" flag to view options:

[email protected] jupyterScripts]$ bash install-jupyter-notebook.sh
Creating new environment now...
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/usd.local/adison.kleinsasser/anaconda3/envs/jupyter
added / updated specs:
- ipykernel
- jupyter
The following packages will be downloaded:
package | build
bleach-3.1.1 | py_0 111 KB conda-forge
gst-plugins-base-1.14.5 | h0935bb2_2 6.8 MB conda-forge

Use "exit" to exit the node.

[email protected] jupyterScripts]$ exit
[email protected] jupyterScripts]$

Why do we request a node for the installation, and then exit out of it to start Jupyter?

Using another node for the installation process (install-jupyter-notebook.sh) keeps the login node open for users logging in, however, the script that starts Jupyter (start-jupyter-notebook.sh)requests a node (within the script), so being in the login node before running it is advised.

Starting Jupyter

(If you are entering the tutorial here, navigate to the directory that contains "start-jupyter-notebook.sh".)

Run start-jupyter-notebook.sh using bash.

Note: to see options for starting Jupyter, add an -h flag to the command:

[email protected] jupyter]$ bash start-jupyter-notebook.sh

If you have already opened Jupyter before (and your password is already set) you may skip to the "Start Tunnel" section.

Set a Password

If you are starting Jupyter for the first time, it will prompt you to create a password for your Jupyter Notebook installation. This can be changed or reset at a later time and is not related to your University password.

Enter your desired password

Note: the cursor will not move as you type- just like when typing the password to log into Lawrence.

Enter your desired password again

Resetting your Password

If you forget your password and need to reset it:

Open your Jupyter environment.

[email protected]@local jupyterScripts]$ conda activate jupyter
(jupyter) [email protected]@local jupyterScripts]$

Then run "jupyter notebook password". Enter a new password when prompted. (Remember, the cursor won't move while typing a password.)

(jupyter) [email protected]@local jupyterScripts]$ jupyter notebook password
Enter password:
Verify password:
[NotebookPasswordApp] Wrote hashed password to /home/usd.local/adison.kleinsasser/.jupyter/jupyter_notebook_config.json
(jupyter) [email protected]@local jupyterScripts]$

Don't forget to deactivate your environment.

(jupyter) [email protected]@local jupyterScripts]$ conda deactivate
[email protected]@local jupyterScripts]$

Why do we bother having a password if it's so easy to reset?

Once the Jupyter server is started, anyone on Lawrence could theoretically access that Jupyter instance if they know the port it is using. The password protects your Jupyter from being accessible by unauthorized people who would have the same read/write access to any files your running Jupyter Notebook session can access.

Start Tunnel

After running the bash start-jupyter-notebook.shcommand (and setting a password if necessary), an ssh command and a localhost link will appear in the terminal (They aren't click-able).

Copy the ssh command from the print-out. (Do not use Ctrl-C, it'll cut off the job).

Don't use Ctrl-C

Open a second terminal, and paste the command into it.

Then hit "Enter".

Back in the first terminal, copy the localhost link:

Then open a browser, and paste it in the address bar (Note: your link will likely be different from the one shown- don't copy the one in the picture).

Press "Enter", then enter your password when prompted:

and Jupyter will come up.

Quit Jupyter

When you are done with Jupyter, don't simply close the browser. Make sure you shut down the server as well. Click on the "Quit" button in Jupyter:

The first terminal will then look like this:

Notice that the command prompt has come back. In the second terminal, use Ctrl-C to bring back the command line.