notebook
notebook copied to clipboard
Resetting notebook_dir on Windows doesn't work
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?
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:
Try conda update notebook traitlets jupyter_core
.
Doesn't work.
It shows:
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)
- Execute jupyter notebook --generate-config
- Open the file generate in the location C:\Users\username.jupyter\jupyter_notebook_config.py
- 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.
Consolidating above steps suggested on what worked for me using Windows 10 : Update Anaconda settings:
- Launch the command prompt from Anaconda by clicking on “Open Terminal” (from any environment)
- 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.
- Open "jupyter_notebook_config.py" file and search for “#c.NotebookApp.notebook_dir = ' ' ‘‘
- 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:\'
- Save it and done with Anaconda. You can stop here, if you don't use any shortcut icons.
Update the Anaconda icon:
- Open Jupyter Notebook shortcut location from start Menu
- Go to properties of that shortcut
- In the Target Section, delete "USERPROFILE" from the entire path and remove anything in the Start in: box
Hope that helps.
Hi guys,
I run into similar issues. I use anaconda 1.9.12. I am able to change the default directory in jupyter_notebook_config.py and it works fine if I start from anaconda. The shortcut overwrites the jupyter_notebook_config.py settings and starts in the default folder. When checking the properties of the shortcut I don't have USERPROFILE and my Start in box says %HOMEPATH% -> If I change anything in Start in box then the shortcut breaks even if I put %HOMEPATH% back.
Any idea what else I could try?
Many thanks
Tom
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.
![]()
I just delete %USERPROFILE% and Jupyter will work fine . Thanks!
I found a "problem", which has to do with anaconda specifically.
Original issue - jupyter notebook wouldn't change the directory, even if I change the location in the config files. As well as simply executing jupyter notebook
in cmd gives an error about a DLL failing to load.
The problem is the environment - if you run activate.bat under [install location]/Anaconda3/Scripts in the command prompt and then execute the same command, it loads the notebook location properly. Looks like Anaconda's implementation of python as such. If you have multiple environments, you probably know more than I do on the topic.
The configs also work if jupyter notebook is launched from anaconda navigator.
EDIT: You can also run the command
conda activate base
after having run conda init
https://stackoverflow.com/questions/69468117/how-to-activate-anaconda-environment (not a lot of information here, but this just tipped me that way)
jupyter notebook --notebook-dir [LOCATION] as a workaround i guess....
@zeka0 I found that you have to add two slashes in Windows for it to work.
c.NotebookApp.notebook_dir = 'E:\\Projects\\JupyterNotebook'
This one works, thanks
I have the same request. Clearly speaking, is it possible to use Environment Variable(e.g. HOME) in c.NotebookApp.notebook_dir? Apparently, using the envvar in the config file will cause the crashing of jupyter book.