How to change the Root/Default directory for files to save (Jupyter ver 7.0.6)

I understand to change the Root or Default directory the following needs to be done:

  • Create Config file
  • Change the following in the config file:
    Add the new directory to:
    ## The directory to use for notebooks and kernels.
    #c.NotebookApp.notebook_dir = ‘’
    XXX
    I could not find this
    What I found in the config file was:
  • Line 944:
    …c.ServerApp.preferred_dir = ‘D:\My Folder\A Jupyter’ {You can see I enterd the directory and removed the # in front}
  • Line 965:
    …c.ServerApp.root_dir = ‘D:\My Folder\A Jupyter’
  • Line 915:
    …c.ServerApp.notebook_dir = ‘D:\My Folder\A Jupyter’

Still, it has not changed the default location for files uploading and saving

Please advise how to change the default file open and save location on Jupyter 7.0.6

Yes, in version 7.x it is c.ServerApp, not c.NotebookApp. preferred_dir is the location where the file browser will start, root_dir is the directory up to which ouser can traverse.

  • Create Config file

How did you create it and where? Is it under one of the paths listed in jupyter --paths config section?

Hi Krassowski.
I found the following on internet and did this to create the config file:

  1. Open the terminal or command prompt on your computer.
  2. Type jupyter notebook --generate-config and press Enter. This will generate a configuration file for Jupyter Notebook.

(I had it generated 2 days ago, deleted it, and regenrated it today)

Its location is at:
C:\Users\user.jupyter

And main Root directory it picks up is
C:\Users\user

Yes it seems to pick up the path of the config file
FROM CMD
C:\Users\user>jupyter --paths
config:
C:\Users\user.jupyter
C:\Users\user\AppData\Roaming\Python\etc\jupyter
K:\Anaconda\etc\jupyter
C:\ProgramData\jupyter
Some of these folders do not exist, line 2 and 4
Line 3 K:.… does not contain a config file, however it has config folders with other stuff in it

I understand that you are editing jupyter_server_config.py file. Do you see any juypter_server_config.json file in these locations which could be overriding your config? Do you see your changes when you run jupyter server --show-config and jupyter notebook --show-config? These commands should show a list of “Loaded config files”.

1 Like

Hi, thanks for trying to assist:

  1. juypter_server_config.json did not find this file

In the mean time I googled it further and found the idea to enter the line in the config file that was not there. I have now 3 lines. Also re-installed Jupyter
The 3 lines:
c.ServerApp.root_dir = ‘D:\My Folder\Aandele\AJupyter\1 BuySell’
c.NotebookApp.notebook_dir = ‘D:\My Folder\Aandele\AJupyter\1 BuySell’
c.ServerApp.preferred_dir = ‘D:\My Folder\Aandele\AJupyter\1 BuySell’

2 run jupyter server --show-config :
I see the following line in there:

File “C:\Users\user.jupyter\jupyter_notebook_config.py”, line 6
c.ServerApp.root_dir = ‘D:\My Folder\Aandele\AJupyter\1 BuySell’
IndentationError: unexpected indent

So it picks my line up, but there is some error. I also tried with :

  File "C:\Users\user\.jupyter\jupyter_notebook_config.py", line 6
    c.ServerApp.root_dir = 'D:\\My Folder\\Aandele\\AJupyter\\1 BuySell'
IndentationError: unexpected indent

3 run jupyter notebook --show-config:
I see ssame as above error message:

File “C:\Users\user.jupyter\jupyter_notebook_config.py”, line 6
c.ServerApp.root_dir = ‘D:\My Folder\Aandele\AJupyter\1 BuySell’
IndentationError: unexpected indent

XXXXXX

I found space infront of the c.xxxxxx, removed them, now I am getting the following error:
[W 2024-01-20 20:28:13.138 ServerApp] notebook | error linking extension: No such directory: ‘‘D:\My Folder\Aandele\AJupyter\x01 BuySell’’

No such directory: ‘‘D:\My Folder\Aandele\AJupyter\x01 BuySell’’

It means that it treats \1 as special character - you need to add escapes, so instead of:

c.ServerApp.root_dir = 'D:\My Folder\Aandele\AJupyter\1 BuySell'

it would be:

c.ServerApp.root_dir = 'D:\\My Folder\\Aandele\\AJupyter\\1 BuySell'
1 Like

Hi Krassowski
Thank you for your Help!!

I have resolved it now, thanks to your assistance Krassowski

1 - remove spaces before the c
2 - I used the following 3, not sure if all 3 are required, with an “r”

c.ServerApp.root_dir = r’D:\My Folder\Aandele\AJupyter\1 BuySell’
c.NotebookApp.notebook_dir = r’D:\My Folder\Aandele\AJupyter\1 BuySell’
c.ServerApp.preferred_dir = r’D:\My Folder\Aandele\AJupyter\1 BuySell’

Note: Above the screen shows \ (only 1) however it is \ + \ 2 as per Krassowski, not sure why it is showing only 1 line

1 Like