0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

How to Change the Root Directory of Jupyter Notebook (on Windows with Anaconda)

Posted at

Introduction

As a part of customizing my development environment, I configured Jupyter Notebook to start in a specific working directory on Windows using Anaconda.
This hands-on setup involved manually editing the jupyter_notebook_config.py file and deepened my understanding of Python environments and configuration files.

Documenting this process in English allows me to share practical know-how with beginners and contribute to the community. This also demonstrates my ability to troubleshoot setup issues and tailor environments to project needs.

Step-by-Step

If "TLyticsInsight" is the PC username, the default location for Jupyter Notebook is the following directory:
C:\Users\TLyticsInsight\.jupyter\jupyter_notebook_config.py

  1. Create the folder you want to set as the root for Jupyter Notebook

    1. Open Anaconda Prompt, navigate to the folder you want to set as the root, and run the following command to generate the configuration file:
      jupyter notebook --generate-config
      
      This will generate the configuration file jupyter_notebook_config.py for Jupyter Notebook.
  2. Change the root directory

    1. Open the configuration file in an editor
      • Open the jupyter_notebook_config.py file with a text editor (e.g., Notepad or VSCode).
    2. Edit the settings to change the directory
      • Look for the setting c.NotebookApp.notebook_dir in the configuration file.
      • If you cannot find it, add the following line at the very bottom of the file.
      • To change the directory to a new path (e.g., C:\Users\TLyticsInsight\Documents\JupyterNotebooks), write:
        # Change the default working directory
        c.NotebookApp.notebook_dir = r'C:\Users\TLyticsInsight\Documents\JupyterNotebooks'
        
      • Add the r prefix to specify the Windows path without escaping characters.
  3. Restart Jupyter Notebook
    After saving the configuration, restart Jupyter Notebook.
    • How to restart:
    1. In the Anaconda Prompt, run the following command:
    bash jupyter notebook
    • With this setup, when you open Jupyter Notebook, the specified folder
    C:\Users\TLyticsInsight\Documents\JupyterNotebooks will be the root directory, and you will be able to manage your notebooks from there.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?