最近,原本正常使用的jupyter notebook,不知道怎么回事,在cmd里启动后,可以跳转浏览器,但打不开页面。显示ERR_FILE_NOT_FOUND。
经过和别的正常电脑对比,发现jupyter notebook在启动时会在runtime文件夹里创建一个json文件和html文件,但是现在不知道什么原因没有创建,所以找不到这个html页面,浏览器显示错误。
在网上查了好久,也没找到类似问题和解决办法。后来想起在jupyter notebook_config.py里查看下这个runtime文件夹的位置是不是配置错误,经过ctrl+f查找后发现了踪迹。
发现里面有这么一段描述:
## 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).
# Default: True
# c.NotebookApp.use_redirect_file = True
大体意思是浏览器环境问题会导致不能跳转。下面也给出了解决办法。
将# c.NotebookApp.use_redirect_file = True注释取消掉,并设为False,使用URL直接跳转。
c.NotebookApp.use_redirect_file = False
完美解决问题!!!