I was wondering if there is a way to set a default folder every time I open JupyterLab. Is there any command I can run through Anaconda PowerShell Prompt? Or a JSON property I can modify in settings tab? Thanks in advance!
How to set default folder in JupyterLab file browser?
6.7k Views Asked by NickS1 AtThere are 4 best solutions below
On
According to the jupyter.org: I configured like this.
Terminal command active your envirnment by conda activate Your_env_name and then jupyter lab --generate-config. jupyter_lab_config.py should be created in dir /home/$USER/.jupyter directory.
Find
# c.LabApp.app_settings_dir = '' and uncomment.
Then give your directory like this.
c.LabApp.app_settings_dir = '/home/$USER/Documents/Jupyter_Notebook'
Similar for jupyter notebook. jupyter notebook --generate-config and then nu-comment and edit like c.NotebookApp.notebook_dir = '/home/UserName/Documents/Jupyter_Notebook'
**NB: /home/$USER/Documents/Jupyter_Notebook is my changed default dir. Change it according to your need. **
On
Follow the answer . Just edit the alias alias my_jupn='source /home/$USER/anaconda3/bin/activate && conda activate MyPy38 && jupyter-notebook --notebook-dir=/home/$USER/Documents/Jupyter_Notebook'
and for JupyterLab alias my_jupl='source /home/$USER/anaconda3/bin/activate && conda activate MyPy38 && jupyter-lab --notebook-dir=/home/$USER/Documents/Jupyter_Notebook'
N.B. Here MyPy38 is your active environment name. and if any error occurs then change $USER to your UserName. Lastly, /home/$USER/Documents/Jupyter_Notebook will be change according to your choice.
On
The command
jupyter notebook --generate-config
will create a config file. The path to this file is displayed in your terminal or PowerShell.
Set the desired folder path as the string c.ServerApp.root_dir in this file and make sure you uncomment the line after you set the string.
Windows users will have to use double backslash in paths, e.g.:
c.ServerApp.root_dir = 'C:\\YOUR\\PATH'
If you want to open specific file in directory
a, saya/notebook.ipynbbut then navigate the file browser to directoryb, relative to the root directory, you can usefile-browser-pathquery in the navigation URL (documented here):You can use this method from command line thanks to
LabApp.default_urltraitlet:You can skip the opening specific file part:
If you want to change the root directory, please see this answer which explains how to do so with
ServerApp.root_dirtraitlet (in older versions of Notebook<7.0 and JupyterLab<3.0 used to be namedNotebookApp.notebook_dir). Again, you can use it from command line, and even specify an absolute path:You can combine the two approaches, e.g.:
If you want to persist the changes (for either default URL or root dir), see the previously linked answer which details how to persist configuration.