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

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


当前回答

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

在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快捷键来执行。

%pwd  #look at the current work dir
%cd   #change to the dir you want 

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

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

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

要在OS X中的Windows上执行下面描述的相同技巧,请创建这个shell脚本

#!/bin/bash
cd $(dirname "$0") && pwd
ipython notebook

将其命名为ipython-notebook.command并使其可执行。

把它放到你想要工作的目录中,然后双击它。