When using the Jupyter notebook, the initial path is often C: \ Users \ USERNAME. In this case, It is difficult to manage python code, and C drives become a mess. So users run Jupyter notebook, go to Desktop, create a new folder and work on it. Because doing this repetitive task every time is inefficient, today I’m going to look at how to set up the initial execution path for Jupyter notebook.
First, launch the anaconda prompt window. At this time, you cannot change the initial path for each virtual environment you want, but it applies to the entire virtual environment including the base. Run the following command:
jupyter notebook --generate-config
The anaconda prompt will tell you where the jupyter_notebook_config.py file was created. Copy that path and paste it into the address bar of File Explorer. Then open the jupyter_notebook_config.py file as a txt file. Use ctrl + F to search dir and find the following code:
## The directory to use for notebooks and kernels. #c.NotebookApp.notebook_dir = '%USERPROFILE%'
Delete the comment # and insert the absolute path between the ‘ ‘ s. Note that you should not use \, but /.
## The directory to use for notebooks and kernels. c.NotebookApp.notebook_dir = 'C:/Users/USERNANE/Desktop/folder_name'
Then you are done 😀
Leave a Reply
You must be logged in to post a comment.