Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
773 views
in Technique[技术] by (71.8m points)

python - Windows Subsystem for Linux (WSL 2) and Jupyter Lab : How to open a Jupyter Notebook saved at the Linux file system?

I have a Jupyter lab installed on Windows. I installed Jupyter Lab on WSL Ubuntu. I can lunch Jupyter Lab from Linux terminal. This will open Jupyter Lab on Chrome browser from which I can start a new Jupyter Notebook with Python [conda env:root]*. However, it only shows the windows file system. I try to open my note book that is saved on the Linux file system using:
$ jupyter lab my_linux_folder/my_notebook.ipynb

Jupyter lab lunches successfully, but cannot open the notebook that is on the Linux file system and gives an error:

Cannot open
Could not find path: /my_notebook.ipynb

Is it possible to open a notebook that is on the Linux file system "wsl$" and how?
How to go to "wsl$" from JupyterLab file browser?
Or more generally how to open a notebook that is saved under "wsl$" ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

WSL 2 issues a dynamic IP address each time you launch WSL 2 -- see MSFT docs.

Personally, I run a Python command within a subshell to print that IP:

jupyter lab --ip $(python3 -c "import subprocess; subprocess.run(['hostname', '-I'], text=True).stdout")

This works for me on Ubuntu 20.04 and Windows 10 build 19041.329.

Note: You'll likely have to visit that IP address instead of localhost, plus the port through which you're running Jupyter, e.g. http://:8888 .

To get my IP address via the CLI I use:

ip addr | grep eth0 | grep inet

I choose the first IP address available, typically using that address without the subnet mask, i.e. the forward slash + number.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...