适用于Linux的Windows子系统(WSL 2)和Jupyter实验室:如何打开保存在Linux文件系统中的Jupyter Notebook? [英] Windows Subsystem for Linux (WSL 2) and Jupyter Lab : How to open a Jupyter Notebook saved at the Linux file system?

查看:456
本文介绍了适用于Linux的Windows子系统(WSL 2)和Jupyter实验室:如何打开保存在Linux文件系统中的Jupyter Notebook?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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地址-

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

我个人而言,我在一个子外壳中运行一个Python命令以打印该IP:

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

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

这对我适用于Ubuntu 20.04和Windows 10内部版本19041.329.

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

注意:您可能必须访问该IP地址而不是本地主机,还要访问运行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的Windows子系统(WSL 2)和Jupyter实验室:如何打开保存在Linux文件系统中的Jupyter Notebook?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆