赞
踩
jupyter的安装参考:python环境安装jupyter-CSDN博客
继上一篇python环境安装jupyter,里面有一个问题,就是启动jupyter(命令jupyter notebook)之后,页面默认显示的是启动时候的路径。
那有没有可能每次启动,让其自动进入项目文件夹呢?
在实际配置之前,可以看一下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进入:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。