1

I tried the answers in How to navigate to a different directory in Jupyter Notebook?, but they didn't work for various reasons:

Some answers are "how to permanently change your Jupyter start-up folder" which I don't want to do. I already did this, I set my start-up folder and I like it. Sometimes I just need to move around.

I tried changing my directory in Anaconda Prompt and launching lab, but it still takes me to my default start-up folder.

cd/d D:\Documents\my_new_folder
jupyter lab

Confirmed the cd worked.

On Windows. enter image description here

a11
  • 3,122
  • 4
  • 27
  • 66
  • Are you sure you've navigated to the folder before running `jupyter lab`? If you type `pwd` (prints current directory you're in) in the terminal after navigating, does the correct path appear? For me the root path in Jupyter Lab is the path from where I executed `jupyter lab`. `cd/d` looks a bit strange, what if you change it to just `cd` – Sandsten Jul 16 '21 at 17:15
  • @Sandsten, yes confirmed. cd/d is to change from c drive to d drive – a11 Jul 16 '21 at 17:27
  • Then you might have set the default starting directory to be `C:/` or something similar. See if you have the following file `C:\Users\[USER]\.jupyter\jupyter_lab_config.py` and comment the line `c.ServerApp.notebook_dir = ''` and/or `c.ServerApp.root_dir = ''`. They might have been set to a path which will override the folder you run `jupyter lab in` – Sandsten Jul 16 '21 at 17:38
  • I've already set my default directory how I want it; on rare occasion, I need to go to a different folder – a11 Jul 16 '21 at 17:39
  • Then just run `jupyter lab --lab_dir="."` to override the default directory and start with the directory you're at now. – Sandsten Jul 16 '21 at 17:43
  • Sorry, should be `jupyter lab --notebook-dir="."` Type `jupyter lab --help` to see all available commands to give – Sandsten Jul 16 '21 at 17:48
  • Glad it worker, wrote up an answer. – Sandsten Jul 16 '21 at 17:53
  • thanks for all the help! – a11 Jul 16 '21 at 17:53

1 Answers1

0

If you've set the default directory in the config file located at C:\Users\[USER]\.jupyter\jupyter_lab_config.py. You can use the option --notebook-dir="." to start Jupyter lab at the current folder you're in.

jupyter lab --notebook-dir="."
Sandsten
  • 727
  • 3
  • 16