当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username
我如何将其更改为另一个位置?
当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username
我如何将其更改为另一个位置?
当前回答
%pwd #look at the current work dir
%cd #change to the dir you want
其他回答
当从命令行启动时,IPython Notebook将使用您的当前工作目录。我利用了这一点,创建了上下文菜单项,直接从Windows资源管理器打开它。不需要快捷方式或批处理脚本!
我的灵感来自于Git for Windows创建的基于注册表的“Git GUI Here/Git Bash Here”条目。这个页面(链接了存档版本)有助于定位正确的键。
第一对是没有任何选择的上下文菜单(例如目录背景)。笔记本将以当前目录作为工作目录打开。
Key: HKCR\Directory\Background\shell\ipythonnb
Value: &IPython Notebook Here
Key: HKCR\Directory\Background\shell\ipythonnb\command
Value: "<full path to IPython notebook>" "%v"
这一对用于单击文件夹时显示的上下文菜单。笔记本将以所选文件夹作为工作目录打开。
Key: HKCR\Directory\shell\ipythonnb
Value: &IPython Notebook Here
Key: HKCR\Directory\shell\ipythonnb\command
Value: "<full path to IPython notebook>" "%1"
注意%v vs %1参数,否则它将不起作用。也不要忘记引用。在我的平台上,IPython Notebook的完整路径是C:\WinPython-32bit-2.7.6.4\IPython Notebook.exe,但这个值显然取决于您的安装。
编辑:AFAICT完整路径是必需的,即使可执行文件在系统路径上。
在Windows上的iPython Notebook中,这对我来说很有效:
cd d:\folder\
对上面的Windows技巧的一个更简单的修改-不需要硬编码目录。
A)创建一个包含以下内容的批处理文件: 注意:批处理文件是一个简单的文本文件,其中包含可以执行的命令 在CMD窗口中运行。它必须有一个'.bat'扩展名,因此… 你需要禁用隐藏已知类型扩展名的文件夹设置)
rem -- start_ipython_notebook_here.bat ---
dir
ipython notebook
pause
B)复制并粘贴批处理文件到任何你想要启动笔记本服务器的文件夹。
(确保它是一个你有权限编辑的文件夹。“C:\”不是一个好的选择。)
C)在Windows资源管理器中双击批处理文件。
笔记本服务器应该像往常一样启动。
找到你的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目录的。
import sys
sys.path.append('C:/')