jupyter notbook保存的文件默认在那
时间: 2023-09-28 12:09:14 浏览: 60
Jupyter Notebook 默认的工作目录是启动 Jupyter Notebook 的目录。你可以在 Notebook 中使用 `os.getcwd()` 来查看当前工作目录。如果你没有在工作目录下创建文件夹或指定保存路径,那么保存的文件将会默认在当前工作目录下。你也可以在 Notebook 中使用 `os.listdir()` 来查看当前工作目录下的文件列表。
相关问题
jupyter notebook保存文件默认
### Jupyter Notebook 文件保存机制
Jupyter Notebook 安装完成后,默认情况下会在用户的主目录下创建一个新的工作区来保存新建立的文件[^1]。对于通过 Anaconda 安装的情况,默认路径可能会位于 C 盘下的用户文件夹内[^2]。
为了更灵活地管理项目,建议创建专门用于存放 Jupyter 笔记本文件的新文件夹。
### 修改默认保存路径的方法
要改变这个默认的行为并指定其他位置作为新的默认保存路径,可以通过编辑 Jupyter 的配置文件实现:
#### 方法一:直接修改配置文件
找到 `jupyter_notebook_config.py` 配置文件中的这一行:
```python
#c.NotebookApp.notebook_dir = ''
```
移除开头的注释符号 (`#`) 并设定目标文件夹路径,例如:
```python
c.NotebookApp.notebook_dir = 'D:\\My_Jupyter_Notebooks'
```
这一步骤确保每次启动 Jupyter Notebook 时都会自动切换至所定义的工作空间[^3]。
#### 方法二:使用命令行参数临时更改
也可以不改动任何配置文件,在命令提示符或终端里运行如下指令来启动服务的同时指明所需的工作目录:
```bash
jupyter notebook --notebook-dir="D:\My_Jupyter_Notebooks"
```
这种方法不会永久影响系统的设置,仅适用于当前会话[^4]。
这样做不仅有助于保持个人资料整洁有序,还能提高工作效率,使资源管理和协作更加便捷[^5]。
jupyter notebook 保存文件默认路径的方法
1. 打开Jupyter Notebook,进入任意一个Notebook文档。
2. 在右上角点击"File"菜单,选择"Save As",弹出文件保存对话框。
3. 在文件保存对话框的左侧,可以看到当前路径,也可以点击上方的"Home"按钮,回到默认路径。
4. 如果需要修改默认路径,可以在Notebook中输入以下代码:
```
import os
notebook_path = os.getcwd()
print(notebook_path)
```
5. 运行以上代码后,会输出当前Notebook的路径。如果想把默认路径设置为当前路径,可以在Notebook中输入以下代码:
```
from notebook.services.config import ConfigManager
ConfigManager().update('notebook', {'default_path': './'})
```
6. 运行以上代码后,再次保存文件时,默认路径就变成了当前路径。
阅读全文
相关推荐















