适用于 Linux (WSL 2) 和 Jupyter Lab 的 Windows 子系统:如何打开保存在 Linux 文件系统中的 Jupyter Notebook? [英] Windows Subsystem for Linux (WSL 2) and Jupyter Lab : How to open a Jupyter Notebook saved at the Linux file system?
问题描述
我在 Windows 上安装了 Jupyter 实验室.我在 WSL Ubuntu 上安装了 Jupyter Lab.我可以在 Linux 终端上享用 Jupyter Lab 午餐.这将在 Chrome 浏览器上打开 Jupyter Lab,从中我可以使用 Python [conda env:root]* 启动一个新的 Jupyter Notebook.但是,它只显示 windows 文件系统.我尝试使用以下方法打开保存在 Linux 文件系统上的笔记本:$ jupyter lab my_linux_folder/my_notebook.ipynb
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 实验室午餐成功,但无法打开 Linux 文件系统上的笔记本并报错:
Jupyter lab lunches successfully, but cannot open the notebook that is on the Linux file system and gives an error:
打不开
找不到路径:/my_notebook.ipynb
Cannot open
Could not find path: /my_notebook.ipynb
是否可以打开位于 Linux 文件系统wsl$"上的笔记本?如何打开?
如何从 JupyterLab 文件浏览器转到wsl$"?
或者更一般地说,如何打开保存在 "wsl$" 下的笔记本?
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$" ?
推荐答案
每次启动 WSL 2 时,WSL 2 都会发布一个动态 IP 地址 -- 查看 MSFT 文档.
WSL 2 issues a dynamic IP address each time you launch WSL 2 -- see MSFT docs.
就个人而言,我在子 shell 中运行 Python 命令来打印该 IP:
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")
这在 Ubuntu 20.04 和 Windows 10 build 19041.329 上对我有用.
This works for me on Ubuntu 20.04 and Windows 10 build 19041.329.
注意:您可能必须访问该 IP 地址而不是 localhost,以及运行 Jupyter 所使用的端口,例如http://:8888 .
要通过我使用的 CLI 获取我的 IP 地址:
To get my IP address via the CLI I use:
ip addr | grep eth0 | grep inet
我选择第一个可用的 IP 地址,通常使用不带子网掩码的地址,即正斜杠 + 数字.
I choose the first IP address available, typically using that address without the subnet mask, i.e. the forward slash + number.
这篇关于适用于 Linux (WSL 2) 和 Jupyter Lab 的 Windows 子系统:如何打开保存在 Linux 文件系统中的 Jupyter Notebook?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!