Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
User232431
Helper III
Helper III

Execute external python script in power bi

Hi , I have python script that has stored in local disk and now i want to execute this script in powerbi desktop

File path : "C/Users/DataUpload.py

 

is there any way to run above script using powerbi Button/ any other way?

 

Thanks.

 

4 REPLIES 4
rohit1991
Super User
Super User

Hi @User232431 ,

Yes, you can execute an external Python script in Power BI Desktop, but Power BI does not support direct execution via a button. Instead, you can use Power Query's Python scripting feature or Power Automate with Power BI Service. In Power Query, navigate to Transform Data → Run Python Script, then use exec(open("C:/Users/DataUpload.py").read()) to execute the script. However, this method is limited to data transformation tasks. If you need to trigger a script dynamically, you can integrate Power Automate with a Power BI button to execute the script via a cloud-based workflow. Another alternative is using R scripts within Power BI if Python execution is restricted. These methods ensure seamless integration of Python automation within Power BI without requiring manual execution.

 

Passionate about leveraging data analytics to drive strategic decision-making and foster business growth.
 Connect with me on LinkedIn: Rohit Kumar

lbendlin
Super User
Super User

what is the result of the script? How are you planning to use that result in Power BI?

Script - Which uses SendGrid package to send mails , can this be happen with powerbi Button?Thanks

Use the Power Automate visual as @rohit1991 suggested.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.