7

I'm trying to set a custom starting directory in Jupyter Notebook. I have edited jupyter_notebook_config.py.

Removed # from line "c.NotebookApp.notebook_dir =", added parameter:

c.NotebookApp.notebook_dir = u'c:\\my\\chosen\\directory'.

But still doesn't work, console coming up with error, and jupyter starting in the default home directory.

I'm using Windows server 2008. According to the manuals, it should work.

Does anyone have a suggestion about my problem?

Thomas K
  • 39,200
  • 7
  • 84
  • 86
Smidelius
  • 71
  • 1
  • 1
  • 3
  • 1
    show the error messages here plz. – zhangxaochen Aug 31 '16 at 14:54
  • Jupyter seems to be inconsistent about how it interprets the path string. The error message should make it clear if this is the problem. Also try @RichSignell's answer below as Jupyter sometimes fails to find the correct config file. – QuesterZen Aug 08 '17 at 01:40

4 Answers4

13

The followings steps work perfectly for me on Windows:

First find which directory Jupyter is looking in for your config file:

jupyter --config-dir

If there is no jupyter_notebook_config.py file in that directory, generate one by typing:

jupyter notebook --generate-config

Then edit the jupyter_notebook_config.py file and add something like:

## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = 'c:\\users\\rsignell\\documents\\github'

Then start your jupyter notebook from any directory:

jupyter notebook

and it will start in the directory you specified.

For more info see: http://jupyter-notebook.readthedocs.io/en/latest/config.html

Rich Signell
  • 14,842
  • 4
  • 49
  • 77
  • This is essentially the correct answer, see also: https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/gqRwT_SxGBw -- in later editions of jupyter notebook it seems that the line is in the auto-generated config file by default, but it is also _commented out_ by default -- so the change only works/goes into effect after un-commenting the line out. (Stupid thing to not be aware of, I know, but I wasn't, so maybe other people are as dumb as I am too.) – Chill2Macht Jan 27 '18 at 16:02
2

Microsoft Windows

Open dos command line by typing cmd on windows explorer address bar. This will open command prompt with current path set to current folder. Type jupyter notebook --notebook-dir=%CD% on commandline to start jupyter notebook (ipython notebook) with current directory as notebook's starting directory

lalthomas
  • 442
  • 5
  • 14
1

I also had the problem, and editing jupyter configuration file didn't work either.

My workaround is to make a batch file that goes to a specified directory, then start jupyter notebook from that directory.

You can use notepad to write the batch file, just save it as an all files and specify the extension as .bat

An easy way is also available from DOS prompt using copy con. First, access command prompt (usually by typing "cmd" and enter). Then:

copy con startjupyter.bat

after that you can specify your directory and start notebook from there, for example if your directory is D:\python_codes :

d:
cd python_codes
jupyter notebook

After that, save the file using CTRL+Z and Enter.

You can run the batch file by calling the name (startjupyter), or click it. For the latter, maybe put it in your desktop for easy access.

Keshan Nageswaran
  • 8,060
  • 3
  • 28
  • 45
bowo
  • 51
  • 8
0

I had also problems with the solutions given here. My solution was quick and dirty then, but it works with Windows. I made a batch-file:

cd C:\[starting Directory]
jupyter notebook
stop

You can start Jupyter with a defined directory when you use different batch-files. For example:

cd C:\datascience

or

cd C:\browsergame