当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username
我如何将其更改为另一个位置?
当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username
我如何将其更改为另一个位置?
当前回答
除了@Matt的方法之外,更改笔记本永久使用的默认目录的一种方法是更改配置文件。首先在cmdline中输入:
$> ipython profile create
使用默认配置文件初始化配置文件。其次,在ipython_notebook_config.py文件中,取消注释并编辑这一行:
# c.NotebookManager.notebook_dir = 'D:\\Documents\\Desktop'
更改D:\\Documents\\Desktop到您喜欢的任何路径。
这对我来说很有用;)
更新:没有c.NotebookManager。notebook_dir了。 现在,取消注释和配置的行是这样的: c.NotebookApp。notebook_dir = 'Z:\\username_example\folder_that_you_whant'
其他回答
%pwd #look at the current work dir
%cd #change to the dir you want
我有32位和64位的python和使用WinPython的ipython,我想要32位和64位的版本指向ipython笔记本的相同工作目录。
我按照上面的建议在这里,我仍然无法让我的设置工作。
以下是我所做的——以防有人需要:
看起来Ipython notebook使用了来自C:\pythonPath\winpythonPath\settings\.ipython\profile_default的配置
尽管ipython locate返回C:\users\Username\.ipython
因此,修改ipython_notebook_config.py文件并没有改变我的工作目录。
另外,ipython profile_create没有在C:\pythonPath\winpythonPath\settings\.ipython\profile_default中创建所需的python文件
我相信有更好的方法,但为了快速解决这个问题,我从C:\users\Username\复制了编辑好的python文件。C:\pythonPath\winpythonPath\settings\.ipython\profile_default
现在(终于)ipython notebook 64位运行并为我提供正确的工作目录
注意在Windows上,我对以下语法没有问题:
c.NotebookApp.notebook_dir = u'C:/Users/Path_to_working_directory'
如果您在Windows中安装了最新版本的Python,则上层解决方案可能不适用于您。我已经安装了Python 3.6.0:: Anaconda 4.3.0(64位),我想更改名为Jupyter的iPython Notebook的工作目录,这就是它为我工作的方式。
步骤1:打开CMD并输入以下命令。
步骤1:CMD
步骤2:现在已经在.jupyter文件夹中生成了一个文件。对我来说,它是c:\用户\管理。jupyter。在那里您将找到一个名为jupyter_notebook_config.py的文件。右键单击并编辑它。添加以下一行并设置工作目录的路径。 在“I:\STUDY\Y2-Trimester-1\Modern Data Science”中设置自己的工作目录
我们做完了。现在你可以重新启动Jupyter Notebook了。希望这对你有用。谢谢
您还可以使用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
要在OS X中的Windows上执行下面描述的相同技巧,请创建这个shell脚本
#!/bin/bash
cd $(dirname "$0") && pwd
ipython notebook
将其命名为ipython-notebook.command并使其可执行。
把它放到你想要工作的目录中,然后双击它。