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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
shanecosgrove1
Frequent Visitor

Schedule Refresh - Python giving an error

Hi,

I am running a python script on top of my dataset in power bi for anomaly detection. The script looks up a pre-trained model on my computer and applies it to the dataset in power bi. Below is the python script that is run in power bi. 

tempsnip.png

 

 

 

 

 

The script runs fine and the dataset refreshes in power bi desktop, but when I publish to power bi service I get the following error when I try to setup schedule refresh.

ModuleNotFoundError: No module named 'matplotlib

 I have checked my environment and I have the compatible version of matplotlib installed. I also have the personal gateway install on the same computer as the python files.

 

Any help would be greatly appreciated.

 

Thanks

3 REPLIES 3
Anonymous
Not applicable

Hi @shanecosgrove1 ,

 

The problem doesn't seem to be in Power BI, I found a similar post on the web, please check if the solution in the picture below helps you.

vcaitlynmstf_0-1638781814509.png

 

 ImportError: No module named matplotlib.pyplot 

 

Hope it helps,


Community Support Team _ Caitlyn

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

ibarrau
Super User
Super User

Hi. I guess I'm trying to understand here. Why would you even import matplotlib in a script? that's a visualization library that you can use in the visuals. You shouldn't include it in the script bringing the data.

You can check the libraries for visualizations in service in here: https://docs.microsoft.com/en-us/power-bi/connect-data/service-python-packages-support#python-packag...

I hope removing that may fix it. If you need to use matplotlib in a visual you have to import it right there.


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

Happy to help!

LaDataWeb Blog

Hi ,

 

I get the same error if I remove the import matplotlib line from the python code. They only reason I added it was to see if it would solve the problem but it doesn't matter if I include or exclude it i still get the same error in service.

 

When using python in power bi the environement needs Pandas and Matplotlib to be installed.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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