首页 > 解决方案 > 如何更改 Anaconda 的默认目录?

问题描述

我喜欢学习python。因此,我在我的 MacBook(Mac OS X High Sierra)上安装了 Anaconda。在我使用 JupyterLab 的第一个绊脚石步骤之后,我意识到所有笔记本和 txt 文件都保存在我的主目录中。但是,我喜欢让文件夹保持整洁。如何更改默认文件夹目录?

因此,我生成了 Jupyter 配置文件

 jupyter notebook --generate-config

然后我将笔记本目录行更改为:

 c.NotebookApp.notebook_dir = '/Users/name/folder/Python_scripts/'

重新启动 Jupyter 后,我期待新文件存放在新文件夹中,但没有任何改变。新文件仍保存在主目录中。

标签: pythonmacosinstallationanaconda

解决方案


默认情况下,Jupyter notebook 将使用终端会话的当前工作目录。使用 jupyter 在终端中执行您要查找的操作:

jupyter notebook --notebook-dir=<some_directory>

这会将内核设置为 in<some_directory> 通常您希望从您想要的目录中启动 jupyter:

cd <directory_you_want>
jupyter notebook

移动你的文件(我假设你想移动你所有的笔记本):

cd ~ && find *.ipynb print0 | xargs -0 -I {} mv {} <directory_you_want>

推荐阅读