How do I start jupyter notebook from command-line to run in my current directory, without editing config files or passing hard paths?
Asked Answered
W

2

6

Juypter notebook currently has a limitation: Starting terminal in current directory

How do I do this from command-line (no Anaconda or other GUI), without the following unacceptable hacky approaches? (and in particular where the notebook directory might well change between invocations, or between users?)

  1. Manually edit the hard path into your jupyter notebook config file, in the c.NotebookApp.notebook_dir parameter

  2. Embed hard paths into your notebook code. Must be absolute paths. (yukky). Also user-dependent. Can't distribute notebooks which handle files properly with paths relative to their install dir. Or across machines.

Wheeled answered 19/12, 2017 at 1:15 Comment(0)
W
7

Best solution found so far (on Unix):

jupyter notebook --notebook-dir  `pwd` &

because

jupyter notebook --notebook-dir  . &

(relative-paths) won't work for commands from inside the notebook.

Wheeled answered 19/12, 2017 at 1:17 Comment(1)
On windows 10 I use jupyter notebook --notebook-dir . Not adding --notebook-dir as described below by @rishi-jain does not work on my environment because somehow I have configured my environment in the past to start in a certain directory when launched from the Windows menu (and I kind of prefer that to stay).Rhyolite
M
2

If you are on Windows, go to command prompt by typing cmd in search box. In cmd prompt, change directory to the path where you want to open Jupyter notebook. This can be done by typing

cd C:\your path here \

Next type in the changed path and press enter/

jupyter notebook

Similarly you can type 'jupyter lab' for jupyter lab

And you are done.

Menstruation answered 2/11, 2018 at 14:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.