当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username
我如何将其更改为另一个位置?
当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username
我如何将其更改为另一个位置?
当前回答
您还可以使用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
其他回答
在命令行输入“jupyter notebook”之前导航到所需的文件夹。
在我的情况下,我所有的python文件都在“D:\ python”。
然后输入命令“jupyter notebook”,你就有了它。您已经更改了工作目录。
运行ipython之前:
将目录更改为您的首选目录 运行ipython
运行ipython后:
使用%cd /输入/your/ preferred /path/here/ 使用%pwd检查当前目录
我将在这里补充一长串的答案。如果您在Windows上/使用Anaconda3,我通过转到文件/Scripts/ipython-script.py完成了这一点,并添加了这些行
import os
os.chdir(<path to desired dir>)
排队前
sys.exit(IPython.start_ipython())
找到你的ipython二进制文件。如果你使用anaconda在mac上安装ipython-notebook,它很可能会在/Users/[name]/anaconda/bin/目录下
在那个目录下,而不是启动你的笔记本
./ipython notebook
添加——notebook-dir=<unicode>选项。
./ipython notebook --notebook-dir=u'../rel/path/to/your/python-notebooks'
我在ipython bin目录中使用bashscript启动我的笔记本:
DIR=$(dirname $0)
$DIR/ipython notebook --notebook-dir=u'../rel/path/to/your/python-notebooks'
注意-到notebook目录的路径是相对于ipython bin目录的。
如果你在linux中使用ipython,那么按照以下步骤: ! cd / directory_name / 您可以尝试在您的linux终端中工作的所有命令。 ! vi file_name.py
只需在linux命令之前指定感叹号(!)符号。