当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username
我如何将其更改为另一个位置?
当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username
我如何将其更改为另一个位置?
当前回答
我将在这里补充一长串的答案。如果您在Windows上/使用Anaconda3,我通过转到文件/Scripts/ipython-script.py完成了这一点,并添加了这些行
import os
os.chdir(<path to desired dir>)
排队前
sys.exit(IPython.start_ipython())
其他回答
只需遵循官方网站上的指南,也复制在下面。对于第一步,而不是复制启动器,您只需转到开始菜单并右键单击打开位置。
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/.
在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快捷键来执行。
当从命令行启动时,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上/使用Anaconda3,我通过转到文件/Scripts/ipython-script.py完成了这一点,并添加了这些行
import os
os.chdir(<path to desired dir>)
排队前
sys.exit(IPython.start_ipython())
试试nbopen模块。当你安装并将其与windows资源管理器集成在一起时,你将能够通过双击打开任何笔记本电脑。