Notebook: Resetting notebook_dir on Windows doesn't work

Created on 9 May 2017  ·  14Comments  ·  Source: jupyter/notebook

Gone desperate, searched the issues but found nothing... so I opened this issue.
I want to reset the starting directory for Jupyter Notebook, I googled that by doing:
in C:\Users\username.jupyter\jupyter_notebook_config.py
Change line #c.NotebookApp.notebook_dir = ''
to c.NotebookApp.notebook_dir = 'your path'.

However, I have tried using r'my path', "my path", or simply escape the '\' in the path string, nothing happened, Jupyter still starts at the user's home directory.
Any ideas?

Most helpful comment

Consolidating above steps suggested on what worked for me using Windows 10 :
Update Anaconda settings:

  1. Launch the command prompt from Anaconda by clicking on “Open Terminal” (from any environment)
  2. The enter the following command : jupyter notebook --generate-config, and wait a few seconds to create a file named “jupyter_notebook_config.py” in your user folder.
  3. Open "jupyter_notebook_config.py" file and search for “#c.NotebookApp.notebook_dir = ' ' ‘‘
  4. Remove the comment and add your desired path inside quotes with double slashes (\). Suppose I want to point it to E drive, it would look like this: c.NotebookApp.notebook_dir = 'E:\'
  5. Save it and done with Anaconda.
    You can stop here, if you don't use any shortcut icons.

Update the Anaconda icon:

  1. Open Jupyter Notebook shortcut location from start Menu
  2. Go to properties of that shortcut
  3. In the Target Section, delete "USERPROFILE" from the entire path and remove anything in the Start in: box

Hope that helps.

All 14 comments

What path are you trying to set it to? Can you show the exact line from your config file? Have you uncommented it?

I have tried as follows:
(1)
c.NotebookApp.notebook_dir = r'E:\Projects\JupyterNotebook'
(2)
c.NotebookApp.notebook_dir = 'E:\Projects\JupyterNotebook'
(3)
c.NotebookApp.notebook_dir = 'E:\Projects\JupyterNotebook\'
(4)
c.NotebookApp.notebook_dir = "E:\Projects\JupyterNotebook"

I have uncommented it, these 4 lines are above are just complete lines I put in that file.
All above didn't work.

As far as I can tell you're doing the right thing. It works on my system. Maybe there's an issue with Windows paths. Can you try with forward slashes / instead of backslashes? I know backslashes are correct on Windows, but Python lets you use forward slashes, and it might behave differently.

Also, do you have the latest version of the notebook package? If not, try updating it.

Changing backslashes to forward slashes didn't work.
The thing I didn't mention is that I used Anaconda3 on my windows, and it includes IPython and Jupyter Notebook.
I tried using 'conda update jupyter' but it says it's already compatible.
Below is a screenshot:
default

Try conda update notebook traitlets jupyter_core.

Doesn't work.
It shows:
default

Okay I think I got something.
It's the shortcut provided by the Anaconda that is mal-functioning.
Jupyter notebook works as intented(start in the right working directory) when fired up using cmd, but it defaults to your home directory when using that shortcut.

I guess the Anaconda shortcut is overriding the config. We don't control that shortcut, so you'll need to ask Anaconda about it: https://github.com/ContinuumIO/anaconda-issues/

@zeka0 I found that you have to add two slashes in Windows for it to work.

c.NotebookApp.notebook_dir = 'E:\\Projects\\JupyterNotebook'

I have found solution for this issue :
Step-1 : Open Jupyter Notebook shortcut location from start Menu
Step-2 : Go to properties of that shortcut
Step-3 : In the Target Section, replace "USERPROFILE" with "Jupyter"

Now Jupyter Notebook using that shortcut will also open in the intended location.
(Location as given in the file jupyter_notebook_config.py)

  1. Execute jupyter notebook --generate-config
  2. Open the file generate in the location C:\Users\username.jupyter\jupyter_notebook_config.py
  3. Used double slashes to update the file c.NotebookApp.notebook_dir = 'C:\Projects\JupyterNotebook'

I have found solution for this issue :
Step-1 : Open Jupyter Notebook shortcut location from start Menu
Step-2 : Go to properties of that shortcut
Step-3 : In the Target Section, replace "USERPROFILE" with "Jupyter"

Now Jupyter Notebook using that shortcut will also open in the intended location.
(Location as given in the file jupyter_notebook_config.py)

Jupyter will crash on my computer if I replace "USERPROFILE" with "Jupyter".
But if you just delete %USERPROFILE%, Jupyter will work fine.
image
image

Consolidating above steps suggested on what worked for me using Windows 10 :
Update Anaconda settings:

  1. Launch the command prompt from Anaconda by clicking on “Open Terminal” (from any environment)
  2. The enter the following command : jupyter notebook --generate-config, and wait a few seconds to create a file named “jupyter_notebook_config.py” in your user folder.
  3. Open "jupyter_notebook_config.py" file and search for “#c.NotebookApp.notebook_dir = ' ' ‘‘
  4. Remove the comment and add your desired path inside quotes with double slashes (\). Suppose I want to point it to E drive, it would look like this: c.NotebookApp.notebook_dir = 'E:\'
  5. Save it and done with Anaconda.
    You can stop here, if you don't use any shortcut icons.

Update the Anaconda icon:

  1. Open Jupyter Notebook shortcut location from start Menu
  2. Go to properties of that shortcut
  3. In the Target Section, delete "USERPROFILE" from the entire path and remove anything in the Start in: box

Hope that helps.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mowe96 picture mowe96  ·  3Comments

ehossain1982 picture ehossain1982  ·  3Comments

fonnesbeck picture fonnesbeck  ·  3Comments

harshinielath picture harshinielath  ·  3Comments

uolter picture uolter  ·  3Comments