当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username

我如何将其更改为另一个位置?


当前回答

通常$ ipython notebook将在终端的当前工作目录下启动笔记本和内核。

但是如果你想指定启动目录,你可以使用——notebook-dir选项,如下所示:

$ ipython notebook——notebook-dir=/path/to/specific/directory

其他回答

要在OS X中的Windows上执行下面描述的相同技巧,请创建这个shell脚本

#!/bin/bash
cd $(dirname "$0") && pwd
ipython notebook

将其命名为ipython-notebook.command并使其可执行。

把它放到你想要工作的目录中,然后双击它。

This might help someone who doesn't want to change config file. If you are on Windows/ using Anaconda3, go to Win Start ->Search for Jupyter Notebook(env). Click on it and the Jupyter opens up. On Jupyter webpage, on right hand side go to New -> Terminal and the terminal window opens up. In this terminal windows change the directory to the working directory, using cd command. Example: cd "c:\User\<user-name>\workingdir". Now in the same terminal window type Jupyter-notebook, this will open Jupyter with the working directory we used in cd command above.

除了@Matt的方法之外,更改笔记本永久使用的默认目录的一种方法是更改配置文件。首先在cmdline中输入:

$> ipython profile create

使用默认配置文件初始化配置文件。其次,在ipython_notebook_config.py文件中,取消注释并编辑这一行:

# c.NotebookManager.notebook_dir = 'D:\\Documents\\Desktop'

更改D:\\Documents\\Desktop到您喜欢的任何路径。

这对我来说很有用;)

更新:没有c.NotebookManager。notebook_dir了。 现在,取消注释和配置的行是这样的: c.NotebookApp。notebook_dir = 'Z:\\username_example\folder_that_you_whant'

如果你在linux中使用ipython,那么按照以下步骤: ! cd / directory_name / 您可以尝试在您的linux终端中工作的所有命令。 ! vi file_name.py

只需在linux命令之前指定感叹号(!)符号。

如果你在windows中使用ipython,那么按照以下步骤:

在程序中导航到ipython notebook,并右键单击它和 进入属性。 在快捷选项卡中,将“开始”目录更改为您所需的目录 目录中。 重新启动内核。