简体   繁体   English

从 Anaconda Navigator 启动 Safari 中的 Jupyter Notebook?

[英]Launch Jupyter Notebook in Safari from Anaconda Navigator?

I would like to change the default browser for starting the Jupyter Notebook directly from Anaconda Navigator (the current browser is Chrome, but I want to open the notebook in Safari).我想更改默认浏览器以直接从 Anaconda Navigator 启动 Jupyter Notebook(当前浏览器是 Chrome,但我想在 Safari 中打开笔记本)。

I can start Jupyter Notebook in Safari by running the following code in Terminal: jupyter notebook --browser safari (based on this answer).我可以通过在终端中运行以下代码在 Safari 中启动 Jupyter Notebook: jupyter notebook --browser safari (基于答案)。

Is there a way to define a different browser for launching the notebook from the Navigator?有没有办法定义一个不同的浏览器来从导航器启动笔记本?

Right, so digging a bit deeper into the Anaconda documentation , I've found that it's pretty simple, actually.对,所以深入研究Anaconda 文档,我发现它实际上非常简单。 I found the config file at ~/.jupyter/jupyter_notebook_config.py , uncommented the default line # c.NotebookApp.browser = '' and modified it so that it points to the Safari's executable: c.NotebookApp.browser = u'open -a /Applications/Google\ Chrome.app %s' .我在~/.jupyter/jupyter_notebook_config.py找到了配置文件,取消了默认行# c.NotebookApp.browser = ''注释并对其进行了修改,使其指向 Safari 的可执行文件: c.NotebookApp.browser = u'open -a /Applications/Google\ Chrome.app %s'

  1. Open Anaconda Prompt and run upyter notebook --generate-config打开 Anaconda 提示运行upyter notebook --generate-config

  2. This writes a file to C:\Users\username\.jupyter\jupyter_notebook_config.py这会将文件写入C:\Users\username\.jupyter\jupyter_notebook_config.py

  3. Copy the link C:\Users\username\.jupyter\ and browse to the file location and open it in IDLE editor复制链接C:\Users\username\.jupyter\并浏览到文件位置并在 IDLE 编辑器中打开它

  4. Search for the following line in the file: #c.NotebookApp.browser = ''在文件中搜索以下行: #c.NotebookApp.browser = ''

  5. Remove the # at the beginning of the line to allow the line to execute.删除行首的 # 以允许该行执行。

  6. Add the browser target link inside the single quotes c.NotebookApp.browser = 'ENTER TARGET LINK HERE'在单引号内添加浏览器目标链接 c.NotebookApp.browser = 'ENTER TARGET LINK HERE'

  7. To find the browser target link, go to search and look for the browser you want to use.要查找浏览器目标链接,go 来搜索并查找您要使用的浏览器。 In your case, Safari.在您的情况下,Safari。

    Right click and select “open file location”右击 select “打开文件位置”
    Right click on the file, select properties and copy the Target link右键单击文件,select 属性并复制目标链接

  8. Paste the target link inside the single quotes and make sure you delete the double quotes and use forward slashes in your path.将目标链接粘贴在单引号内,并确保删除双引号并在路径中使用正斜杠。 (Backslashes are use in double quotes, Forward slashes in single quotes) (反斜杠用在双引号中,正斜杠用在单引号中)

  9. Add %s before closing the single quote, so it reads our path as a browser command and add the letter u before the first single quote to indicate this is a unicode string c.NotebookApp.browser = u'BROWSER TARGET LINK HERE %s' and save the file.在关闭单引号之前添加 %s,因此它将我们的路径读取为浏览器命令,并在第一个单引号之前添加字母 u 以指示这是 unicode 字符串 c.NotebookApp.browser = u'BROWSER TARGET LINK HERE %s'并保存文件。

  10. Go to Anaconda Navigator and launch jupyter notebook. Go 到 Anaconda 导航器并启动 jupyter notebook。 You will see your selected browser being set to Jupyter notebook.您将看到您选择的浏览器被设置为 Jupyter notebook。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM