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

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


当前回答

操作系统Windows 10 蟒蛇2018年版

通过配置文件更改jupyter笔记本的工作目录:

打开cmd提示符(或Anaconda提示符),然后输入'jupyter notebook—generate-config'并按enter 这将自动创建一个文件'jupyter_notebook_config'在'C:\Users\username. config'jupyter \ '文件夹 查找创建的文件'jupyter_notebook_config'并编辑它。 查找#c.NotebookApp。Notebook_dir = " 把你想要的路径放在双引号内,它变成。>c。notebookapp。notebook_dir = 'D:/my_folder/jupiter' 注意使用了正斜杠(/),并且删除了注释(#)。

因此,

#c.NotebookApp.notebook_dir = '' 

编辑成

c.NotebookApp.notebook_dir = 'D:/your/desired/path'

让我们修改Jupyter Notebook快捷图标的路径 6.0在开始菜单中,右键单击快捷方式,打开文件夹位置。 6.1进入文件夹后,建议创建一个Jupyter快捷方式的副本, 6.2右键单击新的快捷图标打开属性,

最后,

6.3在目标文本框中,删除路径末尾的%USERPROFILE%,超长路径应该以jupyter-notebook-script.py结束

搜索我的视频 Jupyter笔记本-更改工作文件夹路径从默认到所需的路径

其他回答

import sys
sys.path.append('C:/')

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.

在命令行输入“jupyter notebook”之前导航到所需的文件夹。

在我的情况下,我所有的python文件都在“D:\ python”。

然后输入命令“jupyter notebook”,你就有了它。您已经更改了工作目录。

当从命令行启动时,IPython Notebook将使用您的当前工作目录。我利用了这一点,创建了上下文菜单项,直接从Windows资源管理器打开它。不需要快捷方式或批处理脚本!

我的灵感来自于Git for Windows创建的基于注册表的“Git GUI Here/Git Bash Here”条目。这个页面(链接了存档版本)有助于定位正确的键。

第一对是没有任何选择的上下文菜单(例如目录背景)。笔记本将以当前目录作为工作目录打开。

Key: HKCR\Directory\Background\shell\ipythonnb
Value: &IPython Notebook Here

Key: HKCR\Directory\Background\shell\ipythonnb\command
Value: "<full path to IPython notebook>" "%v"

这一对用于单击文件夹时显示的上下文菜单。笔记本将以所选文件夹作为工作目录打开。

Key: HKCR\Directory\shell\ipythonnb
Value: &IPython Notebook Here

Key: HKCR\Directory\shell\ipythonnb\command
Value: "<full path to IPython notebook>" "%1"

注意%v vs %1参数,否则它将不起作用。也不要忘记引用。在我的平台上,IPython Notebook的完整路径是C:\WinPython-32bit-2.7.6.4\IPython Notebook.exe,但这个值显然取决于您的安装。

编辑:AFAICT完整路径是必需的,即使可执行文件在系统路径上。

试试nbopen模块。当你安装并将其与windows资源管理器集成在一起时,你将能够通过双击打开任何笔记本电脑。