Create Power BI reports in Jupyter Notebooks

Exploring the Synergy Between Power BI and Jupyter Notebooks

Thiago Carvalho


In today’s data-driven world, where information flows incessantly from every corner, extracting meaningful insights and making informed decisions has become paramount.

Recognizing the significance of seamless data visualization and analysis, Power BI has taken a leap forward with its latest update. This update introduces an exciting integration between Power BI and Jupyter Notebooks, allowing users to create PBI reports within their existing workflow.

In this article, we’ll explore the new functionality of the powerbiclient package, how it integrates with Jupyter, and the challenges to productionize the outputs.

Setting up

First, we have to install the package and configure our environment.

This should be as simple as:

pip install powerbiclient

#For Juyter Lab
pip install powerbiclient
jupyter labextension install @jupyter-widgets/jupyterlab-manager

In my experience, it wasn’t really that simple. Everything seemed to work until I tried to generate the report, then I kept getting errors such as:

Error displaying widget: model not found

I tried updating the packages, creating a new env, disabling and enabling the widgets in Jupyter Lab, and praying to the data gods. Nothing worked, and I couldn’t make the Power BI report appear in Jupyter Lab.

Then I tried Jupyter Notebook, and surprisingly, it worked just fine.

There’s not much information online about the requirements, how to set up the environment, how to get started, or troubleshooting in general. At first look, the library seems unreliable and not robust enough to handle the integration with constantly evolving libraries in Python.

Creating a Report

Once we’ve installed the package, we can import the classes needed for creating a report.

from powerbiclient import QuickVisualize, get_dataset_config, Report
from powerbiclient.authentication import DeviceCodeLoginAuthentication