当前位置:   article > 正文

配置jupyter的启动路径

配置jupyter的启动路径

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

1,背景

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

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

2,配置Jupyter启动路径

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

  1. C:\Users\PC>jupyter notebook --help
  2. Jupyter Notebook - A web-based notebook environment for interactive computing
  3. Options
  4. =======
  5. The options below are convenience aliases to configurable class-options,
  6. as listed in the "Equivalent to" description-line of the aliases.
  7. To see all configurable class-options for some <cmd>, use:
  8. <cmd> --help-all
  9. --debug
  10. Set debug level for the extension and underlying server applications.
  11. Equivalent to: [--ServerApp.log_level=DEBUG --ExtensionApp.log_level=DEBUG]
  12. --show-config
  13. Show the application's configuration (human-readable format)
  14. Equivalent to: [--Application.show_config=True]
  15. --show-config-json
  16. Show the application's configuration (json format)
  17. Equivalent to: [--Application.show_config_json=True]
  18. --generate-config #生成默认配置文件
  19. generate default config file
  20. Equivalent to: [--JupyterApp.generate_config=True]
  21. -y
  22. Answer yes to any questions instead of prompting.
  23. Equivalent to: [--JupyterApp.answer_yes=True]
  24. --allow-root
  25. Allow the server to be run from root user.
  26. Equivalent to: [--ServerApp.allow_root=True]
  27. --no-browser
  28. Prevent the opening of the default url in the browser.
  29. Equivalent to: [--ServerApp.open_browser=False --ExtensionApp.open_browser=False]
  30. --autoreload
  31. Autoreload the webapp
  32. Enable reloading of the tornado webapp and all imported Python packages
  33. when any changes are made to any Python src files in server or
  34. extensions.
  35. Equivalent to: [--ServerApp.autoreload=True]
  36. --script
  37. DEPRECATED, IGNORED
  38. Equivalent to: [--FileContentsManager.save_script=True]
  39. --no-script
  40. DEPRECATED, IGNORED
  41. Equivalent to: [--FileContentsManager.save_script=False]
  42. --expose-app-in-browser
  43. Expose the global app instance to browser via window.jupyterapp.
  44. Equivalent to: [--JupyterNotebookApp.expose_app_in_browser=True]
  45. --custom-css
  46. Load custom CSS in template html files. Default is True
  47. Equivalent to: [--JupyterNotebookApp.custom_css=True]
  48. --log-level=<Enum>
  49. Set the log level by value or name.
  50. Choices: any of [0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL']
  51. Default: 30
  52. Equivalent to: [--Application.log_level]
  53. --config=<Unicode>
  54. Full path of a config file.
  55. Default: ''
  56. Equivalent to: [--JupyterApp.config_file]
  57. To see all available configurables, use `--help-all`.

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

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

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

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

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

  1. C:\Users\PC>
  2. C:\Users\PC>jupyter notebook --generate-config
  3. 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进入:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/499089
推荐阅读
相关标签
  

闽ICP备14008679号