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
-
Create the folder you want to set as the root for Jupyter Notebook
- Open Anaconda Prompt, navigate to the folder you want to set as the root, and run the following command to generate the configuration file:
This will generate the configuration file
jupyter notebook --generate-config
jupyter_notebook_config.py
for Jupyter Notebook.
- Open Anaconda Prompt, navigate to the folder you want to set as the root, and run the following command to generate the configuration file:
-
Change the root directory
- Open the configuration file in an editor
- Open the
jupyter_notebook_config.py
file with a text editor (e.g., Notepad or VSCode).
- Open the
- 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.
- Look for the setting
- Open the configuration file in an editor
-
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.