当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username

我如何将其更改为另一个位置?


当前回答

在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将在终端的当前工作目录下启动笔记本和内核。

但是如果你想指定启动目录,你可以使用——notebook-dir选项,如下所示:

$ ipython notebook——notebook-dir=/path/to/specific/directory

试试nbopen模块。当你安装并将其与windows资源管理器集成在一起时,你将能够通过双击打开任何笔记本电脑。

对于linux和Windows: 只要修改一行,你就可以改变它。

1. Open file

cwp.py

in

C:\Users\[您的计算机名]\Anaconda2

.

2. find the line 

os.chdir (documents_folder)

在文件的末尾。

改为

操作系统。Chdir(“您期望的工作文件夹”)

例如:os.chdir("D:/Jupyter_folder")

3. save and close.

它工作。


更新:

说到MacOS,我找不到ccp .py。 以下是我的发现:

打开你的Macbook终端,运行'jupyter notebook -generate-config'。

它将在/Users/[your_username]/.jupyter/jupyter_notebook_config.py目录下创建一个配置文件

打开配置文件,然后更改这一行#c.NotebookApp。Notebook_dir = " 来 c.NotebookApp。Notebook_dir = '你的路径' 记住这一行也要取消注释。

例如,我将路径更改为“/Users/catbuilts/JupyterProjects/”

Windows 10

Look for the jupyter_notebook_config.py in C:\Users\your_user_name\.jupyter or look it up with cortana. If you don't have it, then go to the cmd line and type: jupyter notebook --generate-config Open the jupyter_notebook_config.py and do a ctrl-f search for: c.NotebookApp.notebook_dir Uncomment it by removing the #. Change it to: c.NotebookApp.notebook_dir = 'C:/your/new/path' Note: You can put a u in front of the first ', change \\\\ to /, or change the ' to ". I don't think it matters. Go to your Jupyter Notebook link and right click it. Select properties. Go to the Shortcut menu and click Target. Look for %USERPROFILE%. Delete it. Save. Restart Jupyter.

当从命令行启动时,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完整路径是必需的,即使可执行文件在系统路径上。