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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
User232431
Helper II
Helper II

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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