网络编程
位置:首页>> 网络编程>> Python编程>> jupyter lab的目录调整及设置默认浏览器为chrome的方法

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

作者:luckywizard  发布时间:2023-07-28 09:44:53 

标签: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-右键点击属性,快捷方式页签有目标,是完整路径,粘在上面即可。注意表示目录的“\”要改变为双“\”

来源:https://blog.csdn.net/luckywizard/article/details/102655407

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com