Jupyter Notebook 在指定的目录进行操作,适用 Mac,Windows

方法一:先在命令行中切换到指定目录,再运行jupyter notebook

这种方法是比较常规的方法,也是最简单的解决方法。

每次运行 jupyter notebook 之前,先在命令行中利用 cd 命令切换目录,然后再运行 jupyter notebook

方法二:修改默认打开位置,适合每次在固定目录运行jupyter notebook

这种方法适合每次在固定目录运行 jupyter notebook

首先,在命令行中输入命令:jupyter notebook --generate-config 生成配置文件,命令执行后,会显示配置文件的路径。

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

打开配置文件 jupyter_notebook_config.py,找到 c.NotebookApp.notebook_dir 配置项,去掉注释,添加指定的目录。

## The directory to use for notebooks and kernels.
#c.NotebookApp.notebook_dir = ''
c.NotebookApp.notebook_dir = 'r'e:/testpath''

在命令行中,运行 jupyter notebook 即可,这样无论命令中当前目录是什么,jupyter notebook打开的目录都是指定的e:\testpath

方法三:jupyter notebook –notebook-dir=’d:/download’

其实 jupyter notebook 命令中已经提供了在指定目录运行的参数 --notebook-dir。这种方法更灵活一些,不用切换目录。当然更不用修改配置文件。

--notebook-dir=<Unicode> (NotebookApp.notebook_dir)
  Default: ''
  The directory to use for notebooks and kernels.

发表回复

登录... 后才能评论