当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username
我如何将其更改为另一个位置?
当我打开Jupyter笔记本(以前是IPython)时,它默认为c:\ users \ username
我如何将其更改为另一个位置?
当前回答
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.
其他回答
我将在这里补充一长串的答案。如果您在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/.
对于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/”
我有一个非常有效的方法来保存笔记本在一个理想的位置在窗口。
一次性活动:确保jupyter-notebook.exe的路径为 保存在环境变量下。 从windows资源管理器或cd打开所需的目录 从命令提示符 从所需文件夹上的windows资源管理器中选择地址 Bar(以完全选择路径标签的方式)并输入jupyter-notebook.exe 瞧! !笔记本从上面打开 所需的文件夹和任何新的笔记本将保存在这个位置。
import sys
sys.path.append('C:/')