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
.
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:
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:
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.
Comments
No comments have yet been submitted. Be the first!