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

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


当前回答

%pwd  #look at the current work dir
%cd   #change to the dir you want 

其他回答

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.

要在OS X中的Windows上执行下面描述的相同技巧,请创建这个shell脚本

#!/bin/bash
cd $(dirname "$0") && pwd
ipython notebook

将其命名为ipython-notebook.command并使其可执行。

把它放到你想要工作的目录中,然后双击它。

对上面的Windows技巧的一个更简单的修改-不需要硬编码目录。

A)创建一个包含以下内容的批处理文件: 注意:批处理文件是一个简单的文本文件,其中包含可以执行的命令 在CMD窗口中运行。它必须有一个'.bat'扩展名,因此… 你需要禁用隐藏已知类型扩展名的文件夹设置)

rem -- start_ipython_notebook_here.bat ---
dir
ipython notebook 
pause

B)复制并粘贴批处理文件到任何你想要启动笔记本服务器的文件夹。

(确保它是一个你有权限编辑的文件夹。“C:\”不是一个好的选择。)

C)在Windows资源管理器中双击批处理文件。

笔记本服务器应该像往常一样启动。

对于Mac OS X,目标目录中有空格(后续使用@pheon)。在第2行$(…)周围添加额外的双引号。参见:https://stackoverflow.com/a/1308838(肖恩·布莱特)

#!/bin/bash
cd "$(dirname "$0")" && pwd
ipython notebook

当我搜索ipython change pwd时,这个问题不断出现,尽管我对笔记本电脑不感兴趣,但我对终端或qtconsole感兴趣。没有找到相关的配置项,我尝试了:

# lines of code to run at IPython startup.
c.InteractiveShellApp.exec_lines = ['%cd /home/paul/mypy']

这是基本的shell类;还有终端和控制台(可能还有笔记本)条目可以进一步定制操作。

从文档来看,import语句在条目中最常见,但似乎许多神奇的命令也能起作用。