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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

Python script error when loading

Hi,

I have 4 visuals of Python script on the same page whenever i switch to different page and come back to the same page. The Visuals shoes unexpexted error. And  then i have to rerun teh script again to  get the visulaization. SO can some one help meerror.JPG 

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Which version of Power BI and Python you use?

Do you set up correct "detected python home directions" and "detected python IDEs" in "Option and settings" for Power BI?

You could check if you do all the right configuration following this article:

https://carldesouza.com/installing-setting-up-python-for-power-bi/

https://www.c-sharpcorner.com/article/power-bi-python-scripting-installation-of-python-ide-visual-st...

If the error still occurs, please share some example of your python scripts.

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

@v-juanli-msft 

 

Here is teh Python script used,

 

 

import matplotlib.pyplot as plt
plt.style.use('seaborn')
plt.plot(dataset['Date'], dataset['Order_Demand_Whse_A'], label = 'Warehouse A')
plt.plot(dataset['Date'], dataset['Order_Demand_Whse_C'], label = 'Warehouse C')
plt.plot(dataset['Date'], dataset['Order_Demand_Whse_J'], label = 'Warehouse J')
plt.plot(dataset['Date'], dataset['Order_Demand_Whse_S'], label = 'Warehouse S')
plt.title('Plot for Warehouse Demands')
plt.xlabel('Date')
plt.ylabel('Warehouse Orders')
plt.legend()
plt.tight_layout()
plt.show()

Hi @Anonymous 

As tested, it works on my side. please check your setting.

Capture7.JPGCapture9.JPG

"swtich to other page" on my side means to click on "Page3", then click on "Page2" to see the python visual still working.

In addition, Please use the lastest version of power bi.

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.