1. 生成默认配置文件
运行cmd, 执行 jupyter notebook --generate-config
C:\Users\John Zhang>jupyter notebook --generate-config
Writing default config to: C:\Users\John Zhang\.jupyter\jupyter_notebook_config.py
2. 编辑配置文件
将 C:\Users\John Zhang.jupyter\jupyter_notebook_config.py 中:
## The directory to use for notebooks and kernels.
#c.NotebookApp.notebook_dir = ''
去掉注释,并修该为相应目标路径(路径必须存在)
## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = 'F:\\AI\jupyterNotebook'
3. 重启Jupyter Notebook
发现路径变为修改后的路径。
打印当前路径:
import os
print(os.path.abspath('.'))