繁体   English   中英

如何从命令行指定 jupyter 笔记本的工作目录

[英]How can i specify the working directory for jupyter notebooks from the command line

我有一个带有 jupyter 笔记本的 python 项目,并希望将它们保存在自己的子目录中(例如jupyter_notebooks )。 现在我想启动 jupyter,以便笔记本将项目根目录用作 cwd,而不是它们所在的目录。像这样:

python -m jupyter --cwd=project\root

有没有办法做到这一点?

您可以使用notebook-dir参数并传递您想要的位置:

jupyter notebook --notebook-dir=YourPath

我认为您正在寻找--notebook-dir参数:

python -m jupyter notebook --notebook-dir=/path/to/directory

或者只是:

jupyter notebook --notebook-dir=/path/to/directory

您可以通过运行jupyter notebook --help查看该命令的所有选项。

如果您希望笔记本服务器始终使用特定目录而不提供参数,您可以通过运行以下命令为笔记本服务器生成配置文件:

jupyter notebook --generate-config

创建的文件的名称将打印到控制台。 然后,在此文件中,取消注释并编辑找到变量c.NotebookApp.notebook_dir的行,例如:

c.NotebookApp.notebook_dir = '/path/to/directory'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM