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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Cannot get my Python Script Working because of importing issues with matplotlib

Hi all,

I am trying to see my python code in Power BI but I am having issues. I wrote my code on Jupyter Notebook and it works properly and shows the plot I want to see. However, when I try to run the same code in Power BI I am getting this error. Help would be appreciated.

 

Feedback Type:
Frown (Error)

Timestamp:
2022-06-28T16:08:34.9176205Z

Local Time:
2022-06-28T12:08:34.9176205-04:00

Session ID:
13ff79aa-df05-4f7a-8691-30b71e869154

Release:
May 2022

Product Version:
2.105.1143.0 (22.05) (x64)

Error Message:
Python script error.
Traceback (most recent call last):
File "C:\Users\z004knym\PythonScriptWrapper_7bcb9799-2e5e-4fcd-96e6-45deaf24f627\PythonScriptWrapper.PY", line 2, in <module>
import os, uuid, matplotlib
ModuleNotFoundError: No module named 'matplotlib'

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

According to the error message, it couldn't find the 'Matplotlib' module from the current directory. You need to install the module explicitly using the pip installer because Matplotlib is not a built-in module (it doesn’t come with the default python installation) in Python. See Install required Python packages 

vjingzhang_1-1656647313446.png

 

However, since you can run the code on Jupyter Notebook correctly, you already have Matplotlib in its environment. I guess probably you have installed Anaconda along with Jupyter Notebook, in this case you can also use Anaconda's Python directory in Power BI because Matplotlib is included in Anaconda. You can refer to PYTHON IN POWER BI: ENABLING PYTHON SCRIPTS WITH ANACONDA ENVIRONMENT 

vjingzhang_0-1656647211885.png

 

Other reference:

https://community.powerbi.com/t5/Custom-Visuals-Development/Python-Integration-Error/td-p/677350 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

According to the error message, it couldn't find the 'Matplotlib' module from the current directory. You need to install the module explicitly using the pip installer because Matplotlib is not a built-in module (it doesn’t come with the default python installation) in Python. See Install required Python packages 

vjingzhang_1-1656647313446.png

 

However, since you can run the code on Jupyter Notebook correctly, you already have Matplotlib in its environment. I guess probably you have installed Anaconda along with Jupyter Notebook, in this case you can also use Anaconda's Python directory in Power BI because Matplotlib is included in Anaconda. You can refer to PYTHON IN POWER BI: ENABLING PYTHON SCRIPTS WITH ANACONDA ENVIRONMENT 

vjingzhang_0-1656647211885.png

 

Other reference:

https://community.powerbi.com/t5/Custom-Visuals-Development/Python-Integration-Error/td-p/677350 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.