Boost Data Analytics: Integrate Python Scripts in Power BI Desktop


You can run Python scripts directly in Power BI Desktop and import the resulting datasets into a Power BI Desktop data model. From this model, you can create reports and share them on the Power BI service. Now, users can seamlessly execute Python scripts directly within Power BI, tapping into a vast array of machine learning frameworks and data science libraries. Join the thriving community of open-source developers as we explore the integration of Python into Power BI, unlocking new potentials in data analysis and visualization.


To work with Python in Power BI, we need to have the following prerequisites.

  1. Python runtime installed: The execution runtime on which the Python scripts will be executed.
  2. Install the required libraries: We need to install Pandas and Seaborn to work with.
  3. Visual Studio code(optional): A code editor to efficiently write Python scripts. This is optional as you can also write Python scripts in the Power BI Script editor. However, I recommend using a code editor as it supports syntax highlighting and other essential features.
  4. Updating Power BI settings: Additionally, we need to update the settings in the Power BI to be able to work with Python in Power BI.

Enable Python scripting

To enable Python scripting in Power BI.

  1. In Power BI Desktop, selectFile>Options and Settings>Options>Python scripting. The Python script options page appears.Python Scripting
  2. If necessary, supply or edit your local Python installation path under Detected Python home directories. In the preceding image, the Python's installation local path is C:\Python. If you have more than one local Python installation, make sure to select the one that you want to use.
  3. SelectOK.
  4. Install necessary libraries pip install pandas pip install matplotlib.

Now you are ready to run the Python scripts in Power BI.


This article has guided us through integrating Python with Power BI, showcasing Python's status as a leading open-source programming language widely adopted in data science and machine learning domains. By incorporating Python into Power BI, we've demonstrated how to surpass the tool's standard functionalities, thereby significantly improving Power BI's performance and capabilities.

Similar Articles