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

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


当前回答

根据官方Jupyter笔记本文档更改

USERPROFILE %

到文件夹路径

文档链接

3.1.1. 更改Jupyter Notebook启动文件夹(Windows)

将Jupyter Notebook启动器从菜单复制到桌面。 右键单击新的启动器并更改目标字段,将%USERPROFILE%更改为包含所有笔记本的文件夹的完整路径。 双击Jupyter Notebook桌面启动器(图标显示[IPy]),启动Jupyter Notebook应用程序。笔记本界面将出现在一个新的浏览器窗口或选项卡中。辅助终端窗口(仅用于错误记录和关机)也将打开。

其他回答

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

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.

您还可以使用AutoHotKey与一个简单的脚本打开一个Jupyter笔记本服务器的默认目录(CTRL+I)或在资源管理器高亮显示的路径(或其他地方与CTRL+SHIFT+I)。

#SingleInstance Force
#NoTrayIcon

SetTitleMatchMode RegEx

; Press CTRL+ALT+I in a Windows Explorer window to launch a IPython notebook server in the current folder.
^+!i::
; Get the current path.
Send ^l
; Backup the current clipboard.
ClipSaved := ClipboardAll
; Copy and save the current path.
Send ^c
ClipWait
x = %Clipboard%
; Restore the clipboard.
Clipboard := ClipSaved
ClipSaved = ; Free the memory in case the clipboard was very large.
; Now, run the IPython notebook server.
RunWait, ipython notebook --notebook-dir "%x%", , min
return

^i::
; Now, run the IPython notebook server.
RunWait, jupyter notebook --notebook-dir "C:\Path\To\Workspace", , min
return

; Press CTRL+ALT+P to kill all Python processes.
^!p::
Run, taskkill /f /im python.exe, , min
return

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

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 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笔记本-更改工作文件夹路径从默认到所需的路径