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

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


当前回答

除了@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'

其他回答

Windows 10

Look for the jupyter_notebook_config.py in C:\Users\your_user_name\.jupyter or look it up with cortana. If you don't have it, then go to the cmd line and type: jupyter notebook --generate-config Open the jupyter_notebook_config.py and do a ctrl-f search for: c.NotebookApp.notebook_dir Uncomment it by removing the #. Change it to: c.NotebookApp.notebook_dir = 'C:/your/new/path' Note: You can put a u in front of the first ', change \\\\ to /, or change the ' to ". I don't think it matters. Go to your Jupyter Notebook link and right click it. Select properties. Go to the Shortcut menu and click Target. Look for %USERPROFILE%. Delete it. Save. Restart Jupyter.

只需在CMD中切换到首选目录,因此如果您在

C:\Users\USERNAME>

像这样改变路径

C:\Users\USERNAME>cd D:\MyProjectFolder

CMD光标将移动到此文件夹

D:\MyProjectFolder>

接下来你可以呼叫木星

D:\MyProjectFolder>jupyter notebook

在Windows上的iPython Notebook中,这对我来说很有效:

cd d:\folder\

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

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

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

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

找到你的ipython二进制文件。如果你使用anaconda在mac上安装ipython-notebook,它很可能会在/Users/[name]/anaconda/bin/目录下

在那个目录下,而不是启动你的笔记本

./ipython notebook

添加——notebook-dir=<unicode>选项。

./ipython notebook --notebook-dir=u'../rel/path/to/your/python-notebooks'

我在ipython bin目录中使用bashscript启动我的笔记本:

DIR=$(dirname $0)
$DIR/ipython notebook --notebook-dir=u'../rel/path/to/your/python-notebooks'

注意-到notebook目录的路径是相对于ipython bin目录的。