Skip to content

Jupyter

In order to open jupyter, you need to load the module anaconda:

module load anaconda

If the base environment is not activate, do the following

conda activate

If you have created your own conda environment, you need to install the jupyter package

conda install jupyter

Installation for julia

First, you need to have python and do the installation of notebook in it. Then, you need to install IJulia in julia.

add IJulia

When you start jupyter, you'll be able to create notebooks in python or julia.

Password

We create a password to secure the access to your jupyter.

For lab:

jupyter lab password

For notebook:

jupyter notebook password

Secure connection

You should secure your jupyter by using an SSL certificate to have an encrypted connexion. Since this is an self-signed certificate it won't be automatically recognised by your browser but it works to secure the connexion.

Here's the command to create it:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout $HOME/.jupyter/mykey.key -out $HOME/.jupyter/mycert.pem

Now, let's configure jupyter to use it.

lab

echo "c.ServerApp.certfile = u'$HOME/.jupyter/mycert.pem'" >> $HOME/.jupyter/jupyter_lab_config.py
echo "c.ServerApp.keyfile = u'$HOME/.jupyter/mykey.key'" >> $HOME/.jupyter/jupyter_lab_config.py

notebook

echo "c.NotebookApp.certfile = u'$HOME/.jupyter/mycert.pem'" >> $HOME/.jupyter/jupyter_notebook_config.py
echo "c.NotebookApp.keyfile = u'$HOME/.jupyter/mykey.key'" >> $HOME/.jupyter/jupyter_notebook_config.py

Start the program

To start the program, we don't want to browser to automatically start so we add the option for that.

jupyter notebook --no-browser

ou

jupyter lab --no-browser

Remote access

You'll need to take a note of the port number that was assigned to your jupiter so you can connect to it remotely. This port number is used to create an ssh tunnel.

ssh mydesktop -L8889:localhost:8889

In this example, port 8889 was allocated to our jupyter, adjust accordingly. Then in your browser you can go to the address https://localhost:8889

You can use this method if you're using the VPN.

Run a notebook

To run a notebook as a program from the command line, you can use this command:

jupyter nbconvert --to notebook --inplace --execute notebook.ipynb