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('.'))