简体   繁体   English

如何在 Windows 10 中将默认浏览器更改为 Microsoft Edge for Jupyter Notebook?

[英]How to change the default browser to Microsoft Edge for Jupyter Notebook in Windows 10?

I've tried the following as suggested in this discussion but it isn't working.我已按照讨论中的建议尝试了以下操作,但它不起作用。

  1. c.NotebookApp.browser = '"C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe" %s' c.NotebookApp.browser = '"C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe" %s'

  2. c.NotebookApp.browser = '"C:/Windows/SystemApps/Microsoft.MicrosoftEdge_8wekyb3d8bbwe/MicrosoftEdge.exe" %s' c.NotebookApp.browser = '"C:/Windows/SystemApps/Microsoft.MicrosoftEdge_8wekyb3d8bbwe/MicrosoftEdge.exe" %s'

  3. c.NotebookApp.browser = 'C:/Windows/SystemApps/Microsoft.MicrosoftEdge_8wekyb3d8bbwe/MicrosoftEdge.exe %s' c.NotebookApp.browser = 'C:/Windows/SystemApps/Microsoft.MicrosoftEdge_8wekyb3d8bbwe/MicrosoftEdge.exe %s'

  4. c.NotebookApp.browser = 'C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe %s' c.NotebookApp.browser = 'C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe %s'

After launching Jupyter Notebook the command prompt is opening but the Edge isn't starting with the notebook.启动 Jupyter Notebook 后,命令提示符正在打开,但 Edge 未随笔记本启动。 Chrome is my default browser in the system and I'd like to keep it that way. Chrome 是我在系统中的默认浏览器,我想保持这种状态。 I'm getting the following message in the Jupyter Notebook command prompt window我在 Jupyter Notebook 命令提示符 window 中收到以下消息

[I 16:23:06.903 NotebookApp] JupyterLab extension loaded from C:\Users\Pradip\anaconda3\lib\site-packages\jupyterlab [I 16:23:06.903 NotebookApp] 从 C:\Users\Pradip\anaconda3\lib\site-packages\jupyterlab 加载的 JupyterLab 扩展

[I 16:23:06.903 NotebookApp] JupyterLab application directory is C:\Users\Pradip\anaconda3\share\jupyter\lab [I 16:23:06.903 NotebookApp] JupyterLab 应用程序目录为 C:\Users\Pradip\anaconda3\share\jupyter\lab

[I 16:23:06.918 NotebookApp] Serving notebooks from local directory: C:\Users\Pradip [I 16:23:06.918 NotebookApp] 从本地目录提供笔记本:C:\Users\Pradip

[I 16:23:06.918 NotebookApp] The Jupyter Notebook is running at: [I 16:23:06.918 NotebookApp] Jupyter Notebook 运行于:

[I 16:23:06.918 NotebookApp] http://localhost:8888/?token=60755565b267fb954a464066911e94ca39fab27da2c067d2 [I 16:23:06.918 NotebookApp] http://localhost:8888/?token=60755565b267fb954a464066911e94ca39fab27da2c067d2

[I 16:23:06.918 NotebookApp] or http://127.0.0.1:8888/?token=60755565b267fb954a464066911e94ca39fab27da2c067d2 [I 16:23:06.918 NotebookApp] 或http://127.0.0.1:8888/?token=60755565b267fb954a464066911e94ca39fab27da2c067d2

[I 16:23:06.918 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [I 16:23:06.918 NotebookApp] 使用 Control-C 停止此服务器并关闭所有内核(两次跳过确认)。

[C 16:23:06.996 NotebookApp] [C 16:23:06.996 NotebookApp]

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

"anaconda" opens the browser that you have by default in your operating system. “anaconda”会打开您在操作系统中默认拥有的浏览器。 So the easiest option is change the default browser of the system所以最简单的选择是更改系统的默认浏览器

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) (反斜杠用在双引号中,正斜杠用在单引号中)

Add %s before closing the single quote, so it reads the 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'在关闭单引号之前添加 %s,因此它将路径作为浏览器命令读取,并在第一个单引号之前添加字母 u 以指示这是 unicode 字符串c.NotebookApp.browser = u'BROWSER TARGET LINK HERE %s'

After a lot of searching and frustration at attempts that did not work, I found the solution with help from this post in conjunction with John Lang's response in the comments.经过大量搜索和对无效尝试的挫败后,我在这篇文章的帮助下找到了解决方案,并结合了 John Lang 在评论中的回复。

Step 1. Open Anaconda Prompt (CMD.exe Prompt) from the Anaconda Start Menu and type步骤 1. 从 Anaconda 开始菜单打开 Anaconda Prompt (CMD.exe Prompt) 并键入

a.一个。 for jupyter notebook:对于 jupyter 笔记本:

jupyter notebook --generate-config

b.湾。 for jupyter lab:对于 jupyter 实验室:

jupyter lab --generate-config

Step 2. This will generate a file name (eg C:\Users......\.jupyter\jupyter_lab_config.py ) that you have to locate on your computer and "open with" NotePad.第 2 步。这将生成一个文件名(例如C:\Users......\.jupyter\jupyter_lab_config.py ),您必须在计算机上找到并“使用”记事本“打开”。

Step 3. Edit the line #c.NotebookApp.browser = '' or #c.LabApp.browser = '' to include the path of the browser you would like to open jupyter notebook or jupyter lab with (I have used FireFox in my example):步骤 3. 编辑行#c.NotebookApp.browser = ''#c.LabApp.browser = ''以包含您想要打开 jupyter notebook 或 jupyter lab 的浏览器的路径(我在我的例子):

c.NotebookApp.browser = '"C:\\Program Files\\Mozilla Firefox\\firefox.exe" %s'

or或者

c.LabApp.browser = '"C:\\Program Files\\Mozilla Firefox\\firefox.exe" %s'

Notes for this step:此步骤的注意事项:

  1. Pay attention to the single and double quotes注意单引号和双引号
  2. Make sure there are two backslashes between items确保项目之间有两个反斜杠
  3. Don't forget the %s不要忘记 %s
  4. Don't forget to remove the # at the start of the line不要忘记删除行首的#
  5. If you don't know what the path of your browser is, look it up on "windows start" button and open the file location.如果您不知道浏览器的路径是什么,请在“Windows 启动”按钮上查找并打开文件位置。 Right click on the app and click on properties.右键单击应用程序,然后单击属性。 The path will be there.路径将在那里。

Step 4. Save the NotePad file and relaunch jupyter notebook or jupyter lab.步骤 4. 保存记事本文件并重新启动 jupyter notebook 或 jupyter lab。 It should now be opening on your chosen browser, regardless of what your default browser is.无论您的默认浏览器是什么,它现在都应该在您选择的浏览器上打开。

If you are using Jupyter Lab, with version 3.0.15, then following are the steps you can follow:如果您使用的是 Jupyter Lab,版本为 3.0.15,那么您可以按照以下步骤操作:

  1. Open terminal/ CMD, and type jupyter-lab --generate-config打开终端/ CMD,然后输入jupyter-lab --generate-config
  2. Navigate to C:\Users\user_name\.jupyter and open the Python file jupyter_lab_config.py导航到C:\Users\user_name\.jupyter并打开 Python 文件jupyter_lab_config.py
  3. You will need to change c.ServerApp.browser您将需要更改c.ServerApp.browser
  4. Put the path of the browser , followed by a space and %s all within a single " " .浏览器的路径,后跟一个空格%s都放在一个" "中。
  5. Remember to uncomment this line before saving the file.请记住在保存文件之前取消注释此行。
  6. Double check- this line should be commented out in this Python file: # c.ServerApp.open_browser = False仔细检查 - 此行应在此 Python 文件中注释掉: # c.ServerApp.open_browser = False

For example, I wanted to use Microsoft Edge as my default browser for Jupyter Lab.例如,我想使用 Microsoft Edge 作为 Jupyter Lab 的默认浏览器。 So, for me:所以,对我来说:

c.ServerApp.browser = 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe %s'
  • Now navigate to the folder you want to open your Jupyter Lab.现在导航到要打开 Jupyter Lab 的文件夹。
  • Open CMD at that location, and type jupyter-lab in CMD.在该位置打开 CMD,然后在 CMD 中键入jupyter-lab

You should be good to go now with your selected browser opening for the Jupyter Lab.您现在应该对 go 很好,为 Jupyter 实验室打开您选择的浏览器。

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

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