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

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


当前回答

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

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/.

其他回答

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

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

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

对于那些在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下MiniConda2/Anaconda2上修改Jupyter或iPython工作目录,可以修改此文件:

C:\Program Files\Miniconda2\cwp.py

并添加项目文件夹位置:development_folder= 'C:\Users\USERNAME\Development' 这是我的用户名\开发在我的情况下。

还需要将:os.chdir(documents_folder)更改为os.chdir(development_folder)

try:
    documents_folder = get_folder_path(FOLDERID.Documents)
    development_folder= 'C:\Users\USERNAME\Development'
except PathNotFoundException:
    documents_folder = get_folder_path(FOLDERID.PublicDocuments)
os.chdir(development_folder)
subprocess.call(args, env=env)

通过使用常规的Jupiter Notebook快捷键来执行。

对于linux和Windows: 只要修改一行,你就可以改变它。

1. Open file

cwp.py

in

C:\Users\[您的计算机名]\Anaconda2

.

2. find the line 

os.chdir (documents_folder)

在文件的末尾。

改为

操作系统。Chdir(“您期望的工作文件夹”)

例如:os.chdir("D:/Jupyter_folder")

3. save and close.

它工作。


更新:

说到MacOS,我找不到ccp .py。 以下是我的发现:

打开你的Macbook终端,运行'jupyter notebook -generate-config'。

它将在/Users/[your_username]/.jupyter/jupyter_notebook_config.py目录下创建一个配置文件

打开配置文件,然后更改这一行#c.NotebookApp。Notebook_dir = " 来 c.NotebookApp。Notebook_dir = '你的路径' 记住这一行也要取消注释。

例如,我将路径更改为“/Users/catbuilts/JupyterProjects/”