How to Get the Full Path to the Current Notebook

This topic explains how to get full path to the current notebook.

Scala

To get the full path in a Scala cell, run the following command in a cell:

%scala
dbutils.notebook.getContext.notebookPath

Python

To get the full path using Python, you have to get the path and save it into a widget in a Scala cell and read it in a Python cell.

  1. Save the value into a widget from Scala cell.

    %scala
    dbutils.widgets.text("notebook", dbutils.notebook.getContext().notebookPath.get)
    
  2. Access the widget value from Python cell.

    %python
    dbutils.widgets.get("notebook")