How to change the Jupyter start-up folder

765,560

Solution 1

Jupyter Notebook and JupyterLab < 3.0

For old Jupyter Notebook interface installed with notebook package and run as jupyter notebook (see the next section for the identical interface installed with nbclassic and run with jupyter nbclassic, and for JupyterLab):

  1. Open cmd (or Anaconda Prompt) and run jupyter notebook --generate-config.

  2. This writes a file to C:\Users\username\.jupyter\jupyter_notebook_config.py.

  3. Browse to the file location and open it in an Editor

  4. Search for the following line in the file: #c.NotebookApp.notebook_dir = ''

  5. Replace by c.NotebookApp.notebook_dir = '/the/path/to/home/folder/'

    Make sure you use forward slashes in your path and use /home/user/ instead of ~/ for your home directory, backslashes could be used if placed in double quotes even if folder name contains spaces as such : "D:\yourUserName\Any Folder\More Folders\"

  6. Remove the # at the beginning of the line to allow the line to execute

JupyterLab >= 3, Jupyter Notebook Classic, and RetroLab

For recent nbclassic and JupyterLab >= 3 use c.ServerApp.root_dir instead of c.NotebookApp.notebook_dir (and jupyter server --generate-config instead of jupyter notebook --generate-config).

For context see migration guide and this question on differences between server and notebook.

Solution 2

cd into the directory or a parent directory (with the intended directory you will work nested in it).

Note it must be a folder (E:\> --- This will not work)

Then just run the command jupyter notebook

Solution 3

I am on Windows 10 but same version of Anaconda.

  1. Click on the Start Menu, then All Programs (just Programs for Win10)
  2. Click on the Anaconda3 folder; mine is Anaconda3 (64-bit)
  3. In there you should see Jupyter Notebook. If you have a virtual environment installed, it will be followed by the environment name like this: Jupyter Notebook (env)
  4. Right-click Jupyter Notebook entry and navigate to More => Open File Location
  5. Right-click the correct Jupyter Notebook entry, then click on Properties
  6. Enter a path in the Start in: box; if the path has spaces in it, you must enclose it in double quotes
  7. Delete "%USERPROFILE%" at the end of the executable path

User navigating to Anaconda3 folder (in Windows ; in AppData), editing properties of "Jupyter Notebook" shortcut, to change its "Start in" command to point to a directory where you want Jupyter to start

Solution 4

First try to run

jupyter notebook --notebook-dir="C:/Your/Desired/Start/Directory/"

in a command line (cmd) to see if the Jupyter notebook opens at the desired location.

If yes, then you can make it a shortcut by:

  1. In a Windows File Explorer or on the desktop, Right click > New > Shortcut

  2. Enter the following location and click next:

jupyter notebook --notebook-dir="C:/Your/Desired/Start/Directory/"

  1. Enter a name for your shortcut and finish

Now you have a shortcut to start Jupyter at the location you want. This works on Windows 7, macOS, and Linux. For windows best to enclose the path in double quotes " as single quotes ' will not work if there is a space in the pathname

Note if you found the error saying the path is not valid, try using common slash / instead of backslash \ in the path like jupyter notebook --notebook-dir="D:/"

Solution 5

I just had the same problem and tested the methods mentioned above. After several trials, I realized that they are partially correct and are not the complete solution. I tested the below in Windows 10 and Anaconda 4.4.0 with python 3.6.

There are two ways to do even though they have only very small difference. Follow the way marneylc suggested above: i.e.

1) Open "Anaconda Prompt" and type jupyter notebook --generate-config

2) You find the file in C:\Users\username\.jupyter\jupyter_notebook_config.py

3) Change the line of #c.NotebookApp.notebook_dir = '' to c.NotebookApp.notebook_dir = 'c:\test\your_root\'

4) Then, go to the shortcut of Jupyter Notebook located in C:\Users\User_name\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)

5) Do the right click and go to the Properties

6) In the Target field, remove %USERPROFILE% as stenlytw suggested above.

7) Then, In the field of Start in, type the same directory of c:\test\your_root\ in jupyter_notebook_config.py

8) Done!

As the simpler way, after step 3, go to C:\Users\User_name\Anaconda3\Scripts

4-2) You can see the file of jupyter-notebook.exe and click it.

5-2) Then, the Jupyter start the folder you specified in jupyter_notebook_config.py. So make the shortcut of this file.

6-2) Done.

Share:
765,560
kchak
Author by

kchak

An inquisitive soul

Updated on August 01, 2022

Comments

  • kchak
    kchak almost 2 years

    I tried following the instructions given on the Jupyter Notebook documentation.

    Unfortunately, I haven't been able to figure it out. Where exactly is this "start in" field?

    I've a windows 7 (64 bit) system, with Anaconda3 installed (not in C drive). I want to change Jupyter start folder location.