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

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


当前回答

我将在这里补充一长串的答案。如果您在Windows上/使用Anaconda3,我通过转到文件/Scripts/ipython-script.py完成了这一点,并添加了这些行

import os
os.chdir(<path to desired dir>)

排队前

sys.exit(IPython.start_ipython())

其他回答

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

在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 change pwd时,这个问题不断出现,尽管我对笔记本电脑不感兴趣,但我对终端或qtconsole感兴趣。没有找到相关的配置项,我尝试了:

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

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

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

This might help someone who doesn't want to change config file. If you are on Windows/ using Anaconda3, go to Win Start ->Search for Jupyter Notebook(env). Click on it and the Jupyter opens up. On Jupyter webpage, on right hand side go to New -> Terminal and the terminal window opens up. In this terminal windows change the directory to the working directory, using cd command. Example: cd "c:\User\<user-name>\workingdir". Now in the same terminal window type Jupyter-notebook, this will open Jupyter with the working directory we used in cd command above.

运行ipython之前:

将目录更改为您的首选目录 运行ipython

运行ipython后:

使用%cd /输入/your/ preferred /path/here/ 使用%pwd检查当前目录