如何修改Jupyter Notebook默认路径?
程序员文章站
2024-03-11 21:36:19
...
最初使用Jupyter Notebook时,直接安装在Python目录下,打开Jupyter Notebook 的时候,默认的文件夹的位置是Python目录,比较乱!于是我想把文件保存到其他的文件夹下。
首先,需要使用Jupyter Notebook 配置命令参数,创建配置文件“jupyter_notebook_config.py”,接着,修改配置文件中默认文件夹参数“c.NotebookApp.notebook_dir ”,详细操作过程如下:
D:\Python\Python36>jupyter-notebook --generate-config
Writing default config to: C:\Users\xiaoyw\.jupyter\jupyter_notebook_config.py
在命令行窗口操作完成此命令后,在用户目录下,如下图所示,将看到产生的配置文件。
用文本编辑器,打开“C:\Users\xiaoyw.jupyter\jupyter_notebook_config.py”文件,查找“notebook_dir”参数
c.NotebookApp.notebook_dir = D:\\06Study\\jupyter_notebook’’
注:去掉此段前面的“#”,不留空格
D:\Python\Python36>jupyter-notebook
[I 20:23:04.866 NotebookApp] Serving notebooks from local directory: D:\06Study\jupyter_notebook
[I 20:23:04.866 NotebookApp] The Jupyter Notebook is running at:
[I 20:23:04.868 NotebookApp] http://localhost:8888/?token=d775c62065d21c4711a0e0ecf1f6d8b154beac621bc26637
[I 20:23:04.868 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 20:23:04.878 NotebookApp]
To access the notebook, open this file in a browser:
file:///C:/Users/xiaoyw/AppData/Roaming/jupyter/runtime/nbserver-4960-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=d775c62065d21c4711a0e0ecf1f6d8b154beac621bc26637
在网页中导入代码。
自定义默认文件夹结果如下:
为了方便快速操作,创建桌面快捷方式。
参考:
《使用Python开发工具Jupyter Notebook学习Tensorflow入门及Tensorboard实践》 CSDN博客 肖永威 2019.01