当前位置:   article > 正文

linux子系统打开jupyterlab,WSL安装Jupyter notebook需要注意的事项

jupyter wsl

WSL安装Jupyter notebook需要注意的事项

WSL安装Jupyter notebook需要注意的事项

常规的Jupyter notebook安装可以参考网上很多资料,这里是由于我的是Windows linux子系统,所以有额外需要注意的东西。记录一下。

打不开浏览器、浏览器找不到文件

先生成config文件,终端输入

jupyter notebook --generate-config

之后进入./jupyter,打开jupyter_notebook_config.py

输入以下四行,定义好自己要用的浏览器,比如我用的火狐,就这样加,其他浏览器相应地改名字就好了。

import webbrowser

webbrowser.register ('firefox',None,webbrowser.GenericBrowser('...浏览器路径(注意是反斜杠/)/firefox.exe'))

c.NotebookApp.open_browser = True

c.NotebookApp.browser = 'firefox'

上面这四行是添加了浏览器,其中后面两行可以直接搜索再对应的位置上更改就好。

接下来在jupyter_notebook_config.py中查找WSL:vim中直接输入/WSL,回车定位,可以找到如下解释:

## Disable launching browser by redirect file

#

# For versions of notebook > 5.7.2, a security feature measure was added that

# prevented the authentication token used to launch the browser from being

# visible. This feature makes it difficult for other users on a multi-user

# system from running code in your Jupyter session as you.

#

# However, some environments (like Windows Subsystem for Linux (WSL) and

# Chromebooks), launching a browser using a redirect file can lead the browser

# failing to load. This is because of the difference in file structures/paths

# between the runtime and the browser.

#

# Disabling this setting to False will disable this behavior, allowing the

# browser to launch by using a URL and visible token (as before).

#c.NotebookApp.use_redirect_file = True

变成

c.NotebookApp.use_redirect_file = False

我们就按他说的办,把最后一行删掉#,把True改成False。这样浏览器就不会再出现找不到文件的问题了。

打开Jupyter notebook超时,一直等待响应

那有可能你和我的习惯一样,都是用像下面这样Ctrl+z来关闭Jupyter的,这样的话,继续启动就会一直等待响应。

cb6d96012105bba49d4ca9978e2cd1ea.png

正确关闭的方法是Ctrl+c:

2726c8e34e39f533ca7d5f33b82e7b3b.png

WSL安装Jupyter notebook需要注意的事项相关教程

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/938811
推荐阅读
相关标签
  

闽ICP备14008679号