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

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


当前回答

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.

其他回答

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

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

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

对上面的Windows技巧的一个更简单的修改-不需要硬编码目录。

A)创建一个包含以下内容的批处理文件: 注意:批处理文件是一个简单的文本文件,其中包含可以执行的命令 在CMD窗口中运行。它必须有一个'.bat'扩展名,因此… 你需要禁用隐藏已知类型扩展名的文件夹设置)

rem -- start_ipython_notebook_here.bat ---
dir
ipython notebook 
pause

B)复制并粘贴批处理文件到任何你想要启动笔记本服务器的文件夹。

(确保它是一个你有权限编辑的文件夹。“C:\”不是一个好的选择。)

C)在Windows资源管理器中双击批处理文件。

笔记本服务器应该像往常一样启动。

如果你在linux中使用ipython,那么按照以下步骤: ! cd / directory_name / 您可以尝试在您的linux终端中工作的所有命令。 ! vi file_name.py

只需在linux命令之前指定感叹号(!)符号。

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

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

您还可以使用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