Skip to content

Dear Internet Explorer user: Your browser is no longer supported

Please switch to a modern browser such as Microsoft Edge, Mozilla Firefox or Google Chrome to view this website's content.

Jupyter Notebook in Windows Subsystem for Linux (WSL)

Here’s a procedure for enabling Jupyter Notebooks to run on a Windows brower from a Linux environment on the same machine.

Whilst setting up a new environment in Windows Subsystem for Linux (WSL) running Ubuntu 22.04, I wanted to enable Jupyter Notebooks to run in Firefox in Windows. Here’s how I was able to achieve this:

Step 1: Install Jupyter Notebooks

Open the Linux command prompt, activate your environment, then enter the following command:

$ sudo apt install jupyter-core

Normally, you should be able to then enter the command jupyter notebook to activate the programme. In this case, it will render an error “Jupyter command ‘jupyter-notebook’ not found”. That’s okay.

The next step is to run a force-reinstall via pip:

$ pip install --upgrade --force-reinstall --no-cache-dir jupyter

Step 2: Edit the BASH configuration file

At the command prompt, enter the following command:

$ nano ~/.bashrc

This will open up the BASH configuration file.

Add the following code to the top of the file after line 8:

alias jupyter-notebook="~/.local/bin/jupyter-notebook --no-browser"

And add the following code to the last line of the file:

export PATH=$PATH:~/.local/bin

Save the file and exit via Ctrl + X.

Editing the BASH configuration file in Windows Subsystem for Linux (accessed via Windows Terminal).

Step 3: Launch Jupyter

You should now be able to enter $ jupyter notebook into the command prompt. You will need to navigate to a preferred browser in Windows and go to http://localhost:8888. The first time you log on, the following screen will be visible:

At the first launch of Jupyter Notebook, you will be offered an opportunity to save a password.

The tokin will be available from the WSL terminal. Use the tokin to set-up a password. If completed successfully, Jupyter Notebook should be visible from your browser window:

Jupyter Notebook working in Firefox browser running on Microsoft Windows.

An instance of Jupyter Lab should also be available from http://localhost:8888/lab when activated with the $ jupyter lab command from the WSL terminal.

Jupyter Lab (in “dark mode”) working from Firefox browser in Microsoft Windows.
   

Comments

No comments have yet been submitted. Be the first!

Have Your Say

The following HTML is permitted:
<a href="" title=""> <b> <blockquote cite=""> <code> <em> <i> <q cite=""> <strike> <strong>

Comments will be published subject to the Editorial Policy.