Teach you how to switch Jupyter default folder

Jupyter has a default folder location. Sometimes our computer space is insufficient and we need to change the location of the folder urgently. How to do it? Let's read the following together:

Once you find the Jupyter notebook configuration file

①The configuration file has been generated

If you have already generated a configuration file, or do not remember whether it has been generated, you can find it by following the steps below:

Enter the command line. How to open the command line window can click on the blue link on the left to refer to my previous articles.

input the command

conda activate 装有jupyter的默认环境
jupyter notebook

 Then follow the runtime folder.

Then run to the parent folder of Roaming, which is here

C:/Users/64859

Then find the .jupyter folder and enter to see if there is a jupyter_notebook_config.py file

C:/Users/64859/.jupyter

This is the configuration file for Jupyter notebook. 

②The configuration file has not been generated yet

If the file is not found, the configuration file should not be generated. Open the environment and enter the following command in your environment:

conda activate 装有jupyter的默认环境
jupyter notebook --generate-config

You will probably see something like this:

Because I didn't generate it at the beginning, I found the picture of @_
小许_big guy and marked it

 This is the generated configuration file and its location.

If you have already generated it, you will see something like this:

 Remember to enter N to cancel the overwrite, in case the important configuration you kept before is gone, then you have to reconfigure it.

In short you have found the configuration file and its location. Go to the next step:

2. Modify the default folder in the configuration file

Add the following line to the configuration file:

c.NotebookApp.notebook_dir = '你想要放的文件夹'
For example, the folder I put here is 'D:/jupyter'

***easter eggs***

Careful students may have noticed the two repeated error messages above when running jupyter notebook:

 In short, it is suggested that we change the name of NotebookApp to ServerApp. The reason for this change is that Jupyter has upgraded from jupyter notebook to a new version of jupyter lab, which supports many new functions such as editing and running other types of files.

But it doesn't matter, as of today, April 2, 2023, c.NotebookApp.notebook_dir is still available. And since I started programming with conda two years ago, until today, the tutorials searched on the Internet have basically used NotebookApp from the beginning to now. This NotebookApp should be supported by traditional juypter, and maybe it will continue to support it in the future.

Too much gossip, back to the topic.

Three save the configuration, restart jupyter notebook

Then it should work.

postscript

This article is written to help my friend configure the Jupyter default folder in advance. There are other problems encountered in the course of time, mainly 2:

1. Unable to start the conda environment with conda activate

2. Start jupyter with the shortcut in the menu bar and jump back to the original folder

The actual solution is mentioned in the new article . Friends who are interested or in need can take a look~

Guess you like

Origin blog.csdn.net/m0_46948660/article/details/129914422