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

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


当前回答

对于那些在windows中使用IPython的人来说,一个巧妙的技巧是,可以在每个项目目录中创建一个IPython图标,以笔记本指向所选的项目打开。这有助于把事情分开。

例如,如果你在C:\fake\example\目录下有一个新项目

复制一个ipython notebook图标到目录中,或者创建一个到windows“cmd”shell的新链接。然后右键点击图标,选择“编辑属性”

设置快捷方式属性为:

Target:
C:\Windows\System32\cmd.exe /k "cd C:\fake\example\directory & C: & ipython notebook --pylab inline"

Start in:
C:\fake\example\directory\

(注意“start in”后面加了斜杠)

这将运行windows命令行,更改您的工作目录,并运行指向该目录的ipython notebook。

在每个项目文件夹中放入一个这样的文件夹,你就会有一个ipython笔记本组,保持良好和独立,同时仍然只需要双击。

更新:IPython已经删除了对pylab的命令行内联的支持,所以如果你有一个更新的IPython版本(或者只是不想要pylab),这个诀窍的修复方法就是消除“——pylab inline”。

更新JUPYTER笔记本~版本4.1.1

在我的测试机器上,正如下面评论中报告的那样,最新的jupyter构建似乎检查了开始目录,并将其作为工作目录启动。这意味着不需要重写工作目录。

因此,你的快捷方式可以像这样简单:

Target (if jupyter notebook in path):
    jupyter notebook

Target (if jupyter notebook NOT in path):
    C:\Users\<Your Username Here>\Anaconda\Scripts\jupyter.exe notebook

如果jupyter notebook不在你的PATH中,你只需要在命令前添加完整的目录引用。如果这不能工作,请尝试从早期版本工作。非常方便的是,现在“Start in:”可以在4.1.1及以后版本的测试中为空。也许他们读了这篇关于SO的文章,喜欢它,这么长时间的赞,没有人再需要它了:)

其他回答

只需遵循官方网站上的指南,也复制在下面。对于第一步,而不是复制启动器,您只需转到开始菜单并右键单击打开位置。

Copy the Jupyter Notebook launcher from the menu to the desktop. Right click on the new launcher and change the “Start in” field by pasting the full path of the folder which will contain all the notebooks. Double-click on the Jupyter Notebook desktop launcher (icon shows [IPy]) to start the Jupyter Notebook App, which will open in a new browser window (or tab). Note also that a secondary terminal window (used only for error logging and for shut down) will be also opened. If only the terminal starts, try opening this address with your browser: http://localhost:8888/.

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

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

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

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

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

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.

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.