admin 管理员组

文章数量: 887018

【问题描述】

打开jupyter notebook后发现命令行停在这样一个黑框框中,没有弹出浏览器,需要自己复制里面的网址到浏览器打开,这样操作太繁琐了。

[I 21:39:08.015 NotebookApp] JupyterLab extension loaded from C:\Users\roy\Anaconda3\lib\site-packages\jupyterlab
[I 21:39:08.015 NotebookApp] JupyterLab application directory is C:\Users\roy\Anaconda3\share\jupyter\lab
[I 21:39:08.015 NotebookApp] Serving notebooks from local directory: C:\Users\roy
[I 21:39:08.015 NotebookApp] The Jupyter Notebook is running at:
[I 21:39:08.015 NotebookApp] http://localhost:8888/?token=d0a958999d7e59da3f097809882e8f40eb5845e3a07cebe8
[I 21:39:08.031 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 21:39:08.109 NotebookApp] No web browser found: could not locate runnable browser.

    To access the notebook, open this file in a browser:
        file:///C:/Users/roy/AppData/Roaming/jupyter/runtime/nbserver-1516-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=d0a958999d7e59da3f097809882e8f40eb5845e3a07cebe8

注意到第七行提示

[W 21:39:08.109 NotebookApp] No web browser found: could not locate runnable browser.

说明没有制定一个能够打开的浏览器让jupyter notebook自己打开。

【解决方法】

step1:win+r→输入‘cmd’→在命令行中输入jupyter notebook --generate-config;

step2:如果出现....?[y/N]的字样,则输入y,回车,得到一个地址,可以按着这个地址找到文件jupyter_notebook_config.py,如下图即在 C:\Users\强哥\.jupyter中找到jupyter_notebook_config.py文件用记事本打开;

 step3:参考https://www.jb51/article/186420.htmhttps://www.jb51/article/186420.htmpython - No web browser found: could not locate runnable browser. Jupyter-notebook - Stack Overflowdfhttps://stackoverflow/questions/55554351/no-web-browser-found-could-not-locate-runnable-browser-jupyter-notebook?noredirect=1需要在jupyter_notebook_config.py文件中加入一行代码c.NotebookApp.browser = u'C:\Program Files\Mozilla Firefox\firefox.exe%s'(这里使用的浏览器是火狐浏览器)

 再ctrl+f查询c.NotebookApp.browser,在下面添加这样的一段代码

import webbrowser 
webbrowser.register( "Firefox", None, webbrowser.GenericBrowser("C:/Program Files/Mozilla Firefox/firefox.exe"))
c.NotebookApp.browser = "Firefox"

 完成!

此时再打开jupyter notebook就可以正常弹开浏览器了~

本文标签: 浏览器 火狐 自动弹出 jupyter notebook