0

I know how to set a working directory or initial directory of Jupyter.

How to change the Jupyter start-up folder

However, when I do such, I don't have access to the parent directory of the working directory. I want to set the root directory of Jupyter to home directory to have access to all directories, but I want to have my specific directory (e.g. my notebooks) as the initial directory that the file browser shows initially, so if I wanted I could go up and browse other directories...

Ahmad
  • 6,124
  • 6
  • 49
  • 90
  • If you want to specific directory to be your default directory, then open your jupyter notebook in the specific directory using `jupyter notebook` – bigbounty Jul 10 '20 at 07:52
  • @bigbounty I wrote that in my question too, but I want two things. To have an initial directory and also a root directory which aren't the same necessarily – Ahmad Jul 10 '20 at 07:55
  • Differentiate "initial" and "root" giving some example – bigbounty Jul 10 '20 at 07:55
  • By "root" I mean the scope of my access (if Jupyter wants to restrict it, for example `/home/aa/bb`), but I don't want the file browser starts at it every time, I may want to intially goes to `/home/aa/bb/cc` instead I go to `cc` manually – Ahmad Jul 10 '20 at 08:02

1 Answers1

1

From my jupyter notebook, I start in the following working directory:

import os
os.getcwd()

'C:\\Users\\...\\my_working_dir'

Suppose I want to access the file 'abc.py' in another directory.

I can use this command directly in my jupyter notebook:

import sys
sys.path.insert(0, 'G:/your_path_where_abc_is/')
from abc import ColumnSelector
os.getcwd() # unnecessary: just to show that the working directory is the same as before

'C:\\Users\\...\\my_working_dir'

So that I can load it from another directory without changing my working directory.

Is this what you were looking for?

Ale
  • 674
  • 6
  • 20
  • directly in your jupyter notebook – Ale Jul 10 '20 at 07:44
  • I do but nothing changes (I mean the browser screen is still in the same working directory) – Ahmad Jul 10 '20 at 07:46
  • Maybe I didn't get your question correctly: this was a way to access files in other directories. – Ale Jul 10 '20 at 07:56
  • you said and `from there I can load files for example`... could you extend your answer to say how you load a file for example? – Ahmad Jul 10 '20 at 08:03
  • Thanks, it might be helpful for loading files or modules... but I meant to have access them in file broweser so that I can load them in browser and run them.... – Ahmad Jul 10 '20 at 08:25