7

I'm writing a bash script that ends by launching jupyter-lab and (ideally) opening a specific notebook.

In jupyter, this is easy to do:

$ jupyter notebook my_folder/my_notebook.ipynb

I can't find any guidance for how to do this in jupyter-lab. Ideas?

Abe
  • 22,738
  • 26
  • 82
  • 111

2 Answers2

9

This seems not to be documented in great detail but there are at least two ways of opening specific files:

Simply using the jupyter lab command (see this comment)

$ jupyter lab my_folder/my_notebook.ipynb

or using the Jupyter URLs. First, you start the jupyter lab server, without browser and then open an URL locating the file of choice:

$ jupyter lab --no-browser &
$ sensible-browser http(s)://<server:port>/<lab-location>/lab/tree/path/to/notebook.ipynb

where sensible-browser can be replaced by the browser of your choice (e.g. google-chrome or firefox) and specific URL parts can be retrieved from the URL displayed by the first command (possibly one could extract and assemble the URL automatically).

The Jupyter URLs seem to be a bit more customizable (offering the choice of workspace, etc).

krassowski
  • 13,598
  • 4
  • 60
  • 92
1

For me it worked to navigate to the directory and running:

$ jupyter lab my_notebook.ipynb 

So no path is needed if you are already in the directory.

Arash
  • 63
  • 5