Considering Jupyter has been installed on your WSL2:
0. Open your wsl shell and navigate to the path you want:
This is the only step your should precede which will open jupyter in the directory you want.
uername@ubuntu:/mnt/c/Users/yourname$ cd
uername@ubuntu:~$
for those who are not familiar with opening wsl jupyter-notebook in windows:
1. Use jupyter-notebook --no-browser
command:
Open your shell and run jupyter-notebook --no-browser
.
For example, since I use my jupyter notebook in Anaconda distribution first I should activate the environment:
uername@ubuntu:~$ conda activate
(base) username@ubuntu:~$ jupyter-notebook --no-browser
2. Open the token address in your browser:
After running the command above you get similar result as the following, This part says what you need to do to open the jupyter notebook on your computer. Note the part that says:
Or copy and paste one of these URLs
http://localhost:8888/?token=f17b5818f9d89ca2cb07e93d0026c2d913d8d4c7cef63f3b
or alternatively, you can hold ctrl
& click
on one of the links to get your wsl juyter notebook on windows.
[I 2021-09-30 11:28:00.279 LabApp] JupyterLab extension loaded from /home/username/anaconda3/lib/python3.8/site-packages/jupyterlab
[I 2021-09-30 11:28:00.279 LabApp] JupyterLab application directory is /home/username/anaconda3/share/jupyter/lab
[I 11:28:00.282 NotebookApp] Serving notebooks from local directory: /home/username
[I 11:28:00.282 NotebookApp] Jupyter Notebook 6.3.0 is running at:
[I 11:28:00.283 NotebookApp] http://localhost:8888/?token=f17b5818f9d89ca2cb07e93d0026c2d913d8d4c7cef63f3b
[I 11:28:00.283 NotebookApp] or http://127.0.0.1:8888/?token=f17b5818f9d89ca2cb07e93d0026c2d913d8d4c7cef63f3b
[I 11:28:00.283 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 11:28:00.286 NotebookApp]
To access the notebook, open this file in a browser:
file:///home/username/.local/share/jupyter/runtime/nbserver-1741-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=f17b5818f9d89ca2cb07e93d0026c2d913d8d4c7cef63f3b
or http://127.0.0.1:8888/?token=f17b5818f9d89ca2cb07e93d0026c2d913d8d4c7cef63f3b
If you don't use --no-browser
argumnet, wsl tries to open the jupyter-notebook on itself and since there is no browser either can exist on wsl, you get an error, although still you get the token address and you can copy it and use in on windows browser.