当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username
我如何将其更改为另一个位置?
当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username
我如何将其更改为另一个位置?
当前回答
运行ipython之前:
将目录更改为您的首选目录 运行ipython
运行ipython后:
使用%cd /输入/your/ preferred /path/here/ 使用%pwd检查当前目录
其他回答
根据官方Jupyter笔记本文档更改
USERPROFILE %
到文件夹路径
文档链接
3.1.1. 更改Jupyter Notebook启动文件夹(Windows)
将Jupyter Notebook启动器从菜单复制到桌面。 右键单击新的启动器并更改目标字段,将%USERPROFILE%更改为包含所有笔记本的文件夹的完整路径。 双击Jupyter Notebook桌面启动器(图标显示[IPy]),启动Jupyter Notebook应用程序。笔记本界面将出现在一个新的浏览器窗口或选项卡中。辅助终端窗口(仅用于错误记录和关机)也将打开。
试试nbopen模块。当你安装并将其与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目录的。
正如MrFancypants在评论中提到的,如果你正在使用Jupyter(你应该这样做,因为它目前取代了旧的IPython Notebook项目),事情就有点不同了。首先,已经没有档案了。
安装Jupyter后,首先检查~/。Jupyter文件夹查看其内容。如果没有配置文件从默认的IPython配置文件迁移(在我的情况下没有),为Jupyter Notebook创建一个新的配置文件:
jupyter notebook --generate-config
这会生成~/.jupyter/jupyter_notebook_config.py文件,其中包含一些有用的注释可能的选项。设置默认目录add。
c.NotebookApp.notebook_dir = u'/absolute/path/to/notebook/directory'
当我在Linux和OS X之间切换时,我想使用一个相对于我的主文件夹的路径(因为它们不同- /Users/username和/home/username),所以我设置了如下内容:
import os
c.NotebookApp.notebook_dir = os.path.expanduser('~/Dropbox/dev/notebook')
现在,每当我运行jupyter笔记本,它打开我想要的笔记本文件夹。我还对整个~/进行了版本化。jupyter文件夹在我的dotfiles存储库,我部署到每一个新的工作机器。
顺便说一句,您仍然可以使用——notebook-dir命令行选项,因此可能一个简单的别名更适合您的需要。
jupyter notebook --notebook-dir=/absolute/path/to/notebook/directory
只需遵循官方网站上的指南,也复制在下面。对于第一步,而不是复制启动器,您只需转到开始菜单并右键单击打开位置。
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/.