解决通过终端启动Jupyter Notebook,浏览器不弹出问题

在启动Anaconda提供的CMD后,输入命令如下:

(datasci) C:\Users\德玛西亚>d:

(datasci) D:\>jupyter notebook

此时本应自动弹出 浏览器,但是我卡在了如下界面:

(datasci) C:\Users\德玛西亚>d:

(datasci) D:\>jupyter notebook
[I 11:37:33.916 NotebookApp] Serving notebooks from local directory: D:\
[I 11:37:33.917 NotebookApp] Jupyter Notebook 6.4.12 is running at:
[I 11:37:33.919 NotebookApp] http://localhost:8888/?token=8b0ed867af61f0bc563f66173bd938554900c31754bcc6bb
[I 11:37:33.920 NotebookApp]  or http://127.0.0.1:8888/?token=8b0ed867af61f0bc563f66173bd938554900c31754bcc6bb
[I 11:37:33.920 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 11:37:33.926 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///C:/Users/%E5%BE%B7%E7%8E%9B%E8%A5%BF%E4%BA%9A/AppData/Roaming/jupyter/runtime/nbserver-12184-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=8b0ed867af61f0bc563f66173bd938554900c31754bcc6bb
     or http://127.0.0.1:8888/?token=8b0ed867af61f0bc563f66173bd938554900c31754bcc6bb

如何让浏览器自动打开jupyter notebook?

在cmd命令终端中输入jupyter notebook --generate-config

(datasci) D:\>jupyter notebook --generate-config

此时,在C盘中找到如下文件

解决通过终端启动Jupyter Notebook,浏览器不弹出问题_第1张图片

 解决通过终端启动Jupyter Notebook,浏览器不弹出问题_第2张图片

 选择用记事本打开(其他也行),查找如下内容:

解决通过终端启动Jupyter Notebook,浏览器不弹出问题_第3张图片

 在该行下面输入以下内容

import webbrowser
webbrowser.register("Chrome",None,webbrowser.GenericBrowser(u"C:\Program Files\Google\Chrome\Application\chrome.exe"))
c.NotebookApp.browser = u'Chrome'

浏览器名称和浏览器路径需要根据你自己选择适用,我选择浏览器为谷歌,路径为C:\Program Files\Google\Chrome\Application\chrome.exe

修改完成后CTRL+S保存

重新启动Jupyter Notebook可以自动弹出页面

解决通过终端启动Jupyter Notebook,浏览器不弹出问题_第4张图片

完美解决!!! 

你可能感兴趣的:(jupyter,python,数据分析)