74

I have recently installed Anaconda 5 and with it Jupyter Notebook. I am excited with its rich functionality but I can not find a way to navigate to directories which are not children. More specifically I have tried to double-click the folder icon but that resulted in the same View.

enter image description here

Your advice will be appreciated.

rf7
  • 1,993
  • 4
  • 21
  • 35

14 Answers14

87

Default root of the Jupyter explorer is the current location (folder) where you start the Jupyter server. With the explorer, you can only navigate to all levels of the children folders, but not the parent's of that location. There is an option to set the root folder --notebook-dir when you start Jupyter. Here is an example that starts Jupyter server and sets the root at D:/my_works/jupyter_ipynbs

jupyter notebook --notebook-dir D:/my_works/jupyter_ipynbs

Similarly, for jupyter lab:

jupyter lab --notebook-dir D:/my_works/jupyter_ipynbs

Once Jupyter is open on the browser, its home or root directory will be what you specified as the value of --notebook-dir, in this case D:/my_works/jupyter_ipynbs. From that point, you can navigate to all its sub-directories.

swatchai
  • 17,400
  • 3
  • 39
  • 58
  • 2
    "With the explorer, you can only navigate to all levels of the children folders, but not the parent's of that location". Why not? I mean, why the explorer doesn't allow to navigate freely over all folders in any direction? Can this behavior be changes somehow, e.g. in the configuration files? Thank you – Confounded Dec 18 '19 at 14:39
  • 2
    @Confounded Please post your comment as a new question. In your question, you can refer to this answer. More people will see and give answer. – swatchai Dec 18 '19 at 15:04
  • I think you need to add double quotes around the path for this to work! – Upulie Han Feb 07 '21 at 13:08
  • @UpulieHan Not need them if the path has no `space`. – swatchai Feb 07 '21 at 14:50
8

For windows user there is another solution. You can create a symbolic link at directory that Jupyter starts working.

from command prompt: ( mklink /D [the name of the link] [target directory]

mklink /D G_Drive G:\DsN20

r.burak
  • 514
  • 5
  • 10
  • 2
    Please explain your answer in a bit more detail with explanations. It is incomprehensible for a some of us, not well versed with computer jargon. \ What is a symbolic link? Will the jupyter notebook still open with the original folder with a newly added option / shortcut to navigate to the linked folder? Or will the jpnb be opened in the new folder only. How will the name "G_Drive" be used for this purpose? – rahul-ahuja Dec 31 '20 at 05:35
  • 1
    Let's assume Jupyter shows you the folders at C:/Users/[your username]. and you want to navigate and use files at another directory for example at D:\Test . all you need to do is 1- open command prompt by ( windows + r and type cmd and enter) . 2- navigate the directory that you are seeing at jupyter notebook home. 3- create a link by command mklink /D linkofgyaan D:\Test 4- ıt's done. now you can see it at Jupiter. Please check the following for more info: https://www.sevenforums.com/tutorials/278262-mklink-create-use-links-windows.html – r.burak Jan 01 '21 at 11:13
  • 1
    This works!! Thank you. But you have to launch the command prompt with admin privileges, ie, search for cmd, right click, run as administrator. – Topchi May 08 '22 at 13:37
  • @r.burak, thank you for sharing your solution. I have found this very helpful :) – tasrif Nov 14 '22 at 22:08
6

I use the next code to set jupyter lab from any root folder. From the Anaconda Prompt:

jupyter lab --notebook-dir "E:/Google Drive/Sediments_Regi"

Between the " " include the desire folder.

dhilt
  • 18,707
  • 8
  • 70
  • 85
Regi
  • 61
  • 1
  • 1
5

On windows, when opening from command prompt, browse to the directory you wish

For example to browse to the directory D/pythonprograms

cd D:
cd pythonprograms

and execute

jupyter lab

this will start the instance with root folder as pythonprograms

enter image description here

Upulie Han
  • 431
  • 1
  • 7
  • 15
ChAnDu353
  • 541
  • 7
  • 11
4

This site describes 3 ways to start jupyter notebooks in specific folder:

  1. By changing your current dir to the specific folder, then starting notebook from there:

cd C:\projects\notebooks
jupyter notebook

  1. By using the notebook-dir parameter while staring notebook:

jupyter notebook --notebook-dir=C:\projects\notebooks\

  1. By creating and editing the configuration file (permanent solution, for all environments): open your Anaconda prompt, run this command

jupyter notebook --generate-config

It will create file .jupyter\jupyter_notebook_config.py in C:\Users<your_user_name>. In this file, find c.NotebookApp.notebook_dir parameter, uncomment it by removing the hash and set the value to the directory of your projects.

c.NotebookApp.notebook_dir = 'C:\projects\notebooks'

Now you can run Jupyter Notebook from the Anaconda prompt (or the Anaconda Navigator), and you’ll start from your preferred directory. Keep in mind that you’ve changed the directory for every environment.

lugger1
  • 1,843
  • 3
  • 22
  • 31
3

In Windows: jupyter notebook "C:\ [route to any folder]" ,also works even if the folder does not contain a jupyter notebook. You can then navigate forward, but not backwards, to open or create a new notebook.

Normek
  • 39
  • 1
  • 2
    [This](https://stackoverflow.com/questions/35254852/how-to-change-the-jupyter-start-up-folder) post explains it very well for windows users – R4444 Dec 30 '18 at 16:14
1

I use Jupyter as plugin in my projects (pipenv install jupyter) and to make it start in current folder comment out notebook_dir option (or set to '' — from Jupyter Notebook docs Config file and command line options):

# ~/.jupyter/jupyter_notebook_config.py

## The directory to use for notebooks and kernels.
# c.NotebookApp.notebook_dir

It is equivalent to writing every time jupyter notebook --notebook-dir . (. — current folder)

Denis
  • 940
  • 12
  • 16
1

In Windows, if you want a permanent change, the shortcut that is installed defaults to

C:\Anaconda3\python.exe C:\Anaconda3\cwp.py C:\Anaconda3 C:\Anaconda3\python.exe C:\Anaconda3\Scripts\jupyter-notebook-script.py "%USERPROFILE%/"

If you change "%USERPROFILE%/" to "C:\your\path", then opening the shortcut will go to the correct folder on startup.

note: I installed Anaconda to C:\Anaconda3, so yours might be a bit different based on where you installed it.

Kakenpi
  • 11
  • 1
1

The easiest solution in my opinion:

  • Open Notepad
  • Paste the command jupyter notebook --NotebookApp.iopub_data_rate_limit=1.0e10
  • Save the notepad file with an extension of .bat instead of .txt
  • Paste the file in which directory you want to initialize your jupyter
  • Double click and open the .bat file
  • Jupyter opens with desired directory as base
  • This way you control the jupyter root directory as and when required and don't really have to perform any manual settings

.bat file created on Desktop

.bat file double clicked and executed

jupyter opens with Desktop as the intended base directory

desertnaut
  • 57,590
  • 26
  • 140
  • 166
1

Make a symbolic link in the default directory to '/'. Then you can get to any file anywhere on the system without needing to know ahead of time which paths were of interest.

mrr
  • 11
  • 1
0

If you open the jupyter notebook from the anaconda navigator, you will be able to move around in the directory structure as you please.

Ray
  • 1
0

As it has been said, you can only navigate to children folders from the directory you started jupyter (or jupyter lab).

A quick hack to access notebooks outside the downstream folder tree is to add a symbolic link on the start jupyter folder:

> ln -s /path/to/desired/folder newfolder

Then you will see the newfolder name on the navigation bar of jupyter and you can access all the files within (no need to re-start jupyter server)

scipio1465
  • 23
  • 5
0

I know this is a bit late, but I faced a similar issue operating jupyter notebook. My situation required me to open two .ipynb present in different folders, but whenever I tried launching two instances of jupyter notebook in their respective folders it only accessed the directory where the first command was run. The solution is very simple, just launch each jupyter notebook server on a different non-reserved port, i.e. 9999.

jupyter notebook --port 9999

Note: default port for the server is 8888 which is why the first folder is only opened despite executing the command in different folders.

0

Simple way : Just type jupyter notebook in the file explorer where ever to open jupyter notebook and press Enter enter image description here

after couple of mins you will jupyter notebook page opening

enter image description here

Bhaskara Arani
  • 1,556
  • 1
  • 26
  • 44