jupyter lab的目录调整及设置默认浏览器为chrome的方法

jupyter lab的目录调整及设置默认浏览器为chrome的方法,第1张

jupyter lab的目录调整及设置默认浏览器为chrome的方法

1. Jupyter 默认目录调整

首先要找到jupyter生成的配置文件 jupyter_notebook_config.py 。如果没有,在 anaconda prompt 中用如下命令生成一个:

jupyter notebook --generate-config

打开文件jupyter_notebook_config.py,在文件中找到

## The directory to use for notebooks and kernels.
#c.NotebookApp.notebook_dir = ''

将默认目录改为 D:/Python_prj/myproject :

## The directory to use for notebooks and kernels.
#c.NotebookApp.notebook_dir = ''
c.NotebookApp.notebook_dir = 'D:/Python_prj/myproject'

2. Jupyter 默认浏览器调整

在文件jupyter_notebook_config.py中,找到

## Specify what command to use to invoke a web browser when opening the notebook.
#  If not specified, the default browser will be determined by the `webbrowser`
#  standard library module, which allows setting of the BROWSER environment
#  variable to override it.
#c.NotebookApp.browser = ''

添加如下代码,将浏览器设为chrome:

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

补充知识:修改anaconda中jupyter notebook的默认浏览器详细说明

1、打开anaconda prompt

2、输入jupyter notebook --generate-config

3、显示出jupyter_notebook_config.py 文件所在目录。找到这个文件,用记事本打开。

4、在# c.NotebookApp.browser = '''' 后加入下面语句块:

import webbrowser

webbrowser.register("chrome",None,webbrowser.GenericBrowser(u"C:\ProgramFiles(x86)\Google\Chrome\Application\chrome.exe"))

c.NotebookApp.browser = 'chrome'

5、上条中红色字体应替换为本机中chrome实际安装地,查看方法为开始菜单-chrome-右键点击属性,快捷方式页签有目标,是完整路径,粘在上面即可。注意表示目录的“”要改变为双“”

以上这篇jupyter lab的目录调整及设置默认浏览器为chrome的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持考高分网。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/zaji/3228004.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-10-04
下一篇 2022-10-04

发表评论

登录后才能评论

评论列表(0条)

保存