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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
lionx
Helper I
Helper I

Python Script Error : The preview for Section1/Query1/Source doesn't exist

I'm using Python Script to GET data from a RESTFUL API. The Python Script works well when I run outside Power BI Environment.

When I try to run Python Script with For Loop, I confront the error "Unable to connect. We encountered an error while trying to connect. Details: "The preview for Section1/Query1/Source doesn't exist.".

lionx_0-1671141459848.png

I have searched on Power BI Community but get no luck. The below links is not a solution for this case as the issue just appear when I try with For Loop (or try with the other Loop). While, the Python Script still works well inside Power BI if I excludes the loop block of code. 

 

Error: The preview for Section1/Query1/Source does... - Microsoft Power BI Community

Python Script Error : The preview for Section1/Que... - Microsoft Power BI Community

Solved: Python script error:"the preview for section 1/que... - Microsoft Power BI Community

 

Are there any solutions for this? Thanks for your time. 

 

 

 

 

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @lionx ,

 

Please check whether you have install Python successfully and install the packages you need correctly.

You may refer to offical blogs as below to learn more details.

For reference: 

Run Python scripts in Power BI Desktop

Use Python in Power Query Editor

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-rzhou-msft 

 

Thank you for your response. I do not think this is the issue from the Python side because it still works well if running Python script without LOOP. All the script also works well when I run the Script outside Power BI environment. 

 

The error just happen when I run the Python script with a code block of LOOP in the Power BI (e.g., For Loop). I suppose this error occur from the Power BI side. 

 

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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