配置jupyter的启动路径

本文介绍了如何在安装JupyterNotebook后,配置使其在启动时自动进入指定的项目文件夹,方法是生成并编辑默认配置文件,将c.ServerApp.root_dir设置为所需路径,从而避免每次都手动指定启动路径。
摘要由CSDN通过智能技术生成

jupyter的安装参考:python环境安装jupyter-CSDN博客

1,背景

继上一篇python环境安装jupyter,里面有一个问题,就是启动jupyter(命令jupyter notebook)之后,页面默认显示的是启动时候的路径。

那有没有可能每次启动,让其自动进入项目文件夹呢?

2,配置Jupyter启动路径

在实际配置之前,可以看一下jupyter notebook有那些命令

C:\Users\PC>jupyter notebook --help
Jupyter Notebook - A web-based notebook environment for interactive computing

Options
=======
The options below are convenience aliases to configurable class-options,
as listed in the "Equivalent to" description-line of the aliases.
To see all configurable class-options for some <cmd>, use:
    <cmd> --help-all

--debug
    Set debug level for the extension and underlying server applications.
    Equivalent to: [--ServerApp.log_level=DEBUG --ExtensionApp.log_level=DEBUG]
--show-config
    Show the application's configuration (human-readable format)
    Equivalent to: [--Application.show_config=True]
--show-config-json
    Show the application's configuration (json format)
    Equivalent to: [--Application.show_config_json=True]
--generate-config  #生成默认配置文件
    generate default config file
    Equivalent to: [--JupyterApp.generate_config=True]
-y
    Answer yes to any questions instead of prompting.
    Equivalent to: [--JupyterApp.answer_yes=True]
--allow-root
    Allow the server to be run from root user.
    Equivalent to: [--ServerApp.allow_root=True]
--no-browser
    Prevent the opening of the default url in the browser.
    Equivalent to: [--ServerApp.open_browser=False --ExtensionApp.open_browser=False]
--autoreload
    Autoreload the webapp
        Enable reloading of the tornado webapp and all imported Python packages
        when any changes are made to any Python src files in server or
        extensions.
    Equivalent to: [--ServerApp.autoreload=True]
--script
    DEPRECATED, IGNORED
    Equivalent to: [--FileContentsManager.save_script=True]
--no-script
    DEPRECATED, IGNORED
    Equivalent to: [--FileContentsManager.save_script=False]
--expose-app-in-browser
    Expose the global app instance to browser via window.jupyterapp.
    Equivalent to: [--JupyterNotebookApp.expose_app_in_browser=True]
--custom-css
    Load custom CSS in template html files. Default is True
    Equivalent to: [--JupyterNotebookApp.custom_css=True]
--log-level=<Enum>
    Set the log level by value or name.
    Choices: any of [0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL']
    Default: 30
    Equivalent to: [--Application.log_level]
--config=<Unicode>
    Full path of a config file.
    Default: ''
    Equivalent to: [--JupyterApp.config_file]

To see all available configurables, use `--help-all`.

我们这次可以使用--generate-config来生成一个默认的配置文件
PS:可以看到配置文件路径的提示:

C:\Users\PC>jupyter notebook --generate-config
Writing default config to: C:\Users\PC\.jupyter\jupyter_notebook_config.py   #生成的路径

用记事本打开文件,修改默认文件夹的配置:

将c.ServerApp.root_dir 设置为项目路径

保存并重启jupyter,可以看到即使是从C盘启动的jupyter,打开之后的目录是指定的目录

C:\Users\PC>
C:\Users\PC>jupyter notebook --generate-config
Writing default config to: C:\Users\PC\.jupyter\jupyter_notebook_config.py

PS:网上很多说法是设定c.ServerApp.notebook_dir = 'D:\jupyter_workspace',这个也可以。
配置文件里面提示说这个配置已经不推荐,推荐使用root_dir,所以我这边用的root_dir的方式设置的。

jupyter相关的文档可以从下面的help进入:

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值