如何设置Jupyter Notebook在浏览器上自动打开 [英] How to set jupyter notebook to open on browser automatically
问题描述
因此,尝试打开jupyter笔记本时没有问题,但是由于某种原因,无论我要做什么,我都无法自动在浏览器中打开它.我按照这些帖子无济于事: 无法在浏览器上打开jupyter(ipython)笔记本 https://github.com/jupyter/notebook/issues/2130
So I don't have issues trying to open the jupyter notebook but for some reason, I cannot get it to open in the browser automatically no matter what I'm trying to do. I follow these posts to no avail: unable to open jupyter(ipython) notebook on browser https://github.com/jupyter/notebook/issues/2130
我通过jupyter notebook --generate-config
创建了jupyter配置,并修改了以下设置:
I created the jupyter config through jupyter notebook --generate-config
and modified these settings:
c.NotebookApp.browser ='C:\ Program Files(x86)\ Google \ Chrome \ Application \ chrome.exe'
c.NotebookApp.open_browser = True
c.NotebookApp.webbrowser_open_new = 2
c.NotebookApp.browser = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
c.NotebookApp.open_browser = True
c.NotebookApp.webbrowser_open_new = 2
它仍然无法自动以chrome打开笔记本电脑.我想知道我是否在做一些愚蠢的事情,但是我不知道该怎么做.我在Windows 10上运行,并通过cygwin启动jupyter.当我在cygwin中键入jupyter notebook
(在修改设置文件之后)时,它会显示以下输出:
It still does not open the notebook automatically in chrome. I wonder if I am doing something stupid but I can't figure out what else to do. I am running on Windows 10 and launching jupyter through cygwin. When I type jupyter notebook
(after modifying the settings file) in cygwin, it gives me this output:
$ jupyter notebook
[I 21:57:41.782 NotebookApp] Serving notebooks from local directory: /cygdrive/c/home
[I 21:57:41.782 NotebookApp] The Jupyter Notebook is running at:
[I 21:57:41.782 NotebookApp] http://localhost:8888/?token=373da6a3a3ed7c5fb991f0b3b1042bff22e3fa946aea8bc1
[I 21:57:41.782 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 21:57:41.799 NotebookApp]
To access the notebook, open this file in a browser:
file:///cygdrive/c/home/.local/share/jupyter/runtime/nbserver-1003-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=373da6a3a3ed7c5fb991f0b3b1042bff22e3fa946aea8bc1
还有其他什么方法可以使其在浏览器中自动打开?
Is there anything else I can do to make it open in the browser automatically?
更新:我找到了此链接,它也不起作用:启动IPython笔记本使用选定的浏览器
Update: I found this link and it doesn't work either: Launch IPython notebook with selected browser
我还发现此设置是错误的:c.NotebookApp.browser = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
,应该是:c.NotebookApp.browser = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
.但是我仍然没有取得任何进展. :(
I also found that this setting was wrong: c.NotebookApp.browser = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
, it is supposed to be: c.NotebookApp.browser = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
. But I still haven't made any progress. :(
推荐答案
将此行添加到您的jupyter_notebook_config.py
文件中:
Add this line to your jupyter_notebook_config.py
file:
c.NotebookApp.use_redirect_file = False
这应该使用localhost
/127.0.0.1
URL在浏览器中自动打开jupyter笔记本.
This should open jupyter notebooks automatically in your browser with the localhost
/127.0.0.1
URL.
出于完整性考虑的更多信息:
More info for the sake of completeness:
- 配置文件应该在
~/.jupyter/jupyter_notebook_config.py
中找到.如果丢失,可以使用以下命令生成(如您所做的):jupyter notebook --generate-config
- 这是 Github问题,其中讨论了更改(同样的解决方案也是突出显示此处)
- 以下是文档
- The config file should be found in
~/.jupyter/jupyter_notebook_config.py
. If missing can be generated (as you did) with the command:jupyter notebook --generate-config
- Here's the Github issue where the change was discussed (the same solution was also highlighted here)
- Here's the reference in the documentation
这篇关于如何设置Jupyter Notebook在浏览器上自动打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!