如何在Safari中打开Jupyter Notebook?

5
我使用的是Mac OS操作系统,我的默认浏览器是Firefox。
在终端中,我运行了命令jupyter notebook --generate-config。然后,在文本编辑器中打开了~/.jupyter/jupyter_notebook_config.py文件。
我将c.NotebookApp.browser = u''更改为c.NotebookApp.browser = u'/Applications/Safari.app/Contents/MacOS/Safari %s' 然而,当我运行jupyter notebook时,我得到了以下输出:
```
[I 15:14:23.717 NotebookApp] [nb_conda_kernels] enabled, 3 kernels found
[I 15:14:24.586 NotebookApp] [nb_anacondacloud] enabled
[I 15:14:24.589 NotebookApp] [nb_conda] enabled
[I 15:14:24.626 NotebookApp] ✓ nbpresent HTML export ENABLED
[W 15:14:24.626 NotebookApp] ✗ nbpresent PDF export DISABLED: No module named nbbrowserpdf.exporters.pdf
[I 15:14:24.632 NotebookApp] Serving notebooks from local directory: /Users/ironaut/Tutorials/DAND/Jupyter
[I 15:14:24.632 NotebookApp] 0 active kernels 
[I 15:14:24.632 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=74a348c3fdec07e929dde216c244e1a9164badc47f079819
[I 15:14:24.632 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Failed to acquire exclusive access to history store at file:///Users/ironaut/Library/Safari/History.db. Falling back to an in-memory history store.
[W 15:22:55.201 NotebookApp] 401 POST /login?next=%2Ftree%3F (::1) 1.30ms referer=http://localhost:8888/login?next=%2Ftree%3F
```

如果不更改配置文件,jupyter在Firefox中可以正常启动。


如果您认为我的答案解决了您的问题,请请求接受它作为答案,这样其他人就会知道我的解决方案是有效的。 - Drj
除非您在配置文件中更改,否则Jupyter笔记本将在默认浏览器中打开。 - abggcv
2个回答

14

你几乎完成了所有步骤。再次重申,以使读者受益。

确保 firefox 是默认浏览器。或者使用其他浏览器。

我使用 atom 作为文本编辑器。可以随意使用其他编辑器。

执行

$ jupyter notebook --generate-config
$ atom ~/.jupyter/jupyter_notebook_config.py

查找并更改

c.NotebookApp.browser = u''

c.NotebookApp.browser = u'/usr/bin/open -a Safari %s'

测试

$ jupyter notebook

6
如果这个解决方案解决了你的问题,按照惯例请接受答案,这样别人就会知道它有效,帮助你的人也会因此获得奖励积分。 - Jim

0

打开:vim .jupyter/jupyter_notebook_config.py

查找 > c.NotebookApp.ip = ‘localhost’ 更改 > c.NotebookApp.ip = ‘127.0.0.1’

请记得去掉开头的 # 符号。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接