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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Eraclea
New Member

Import image with Python script

Hi,

 

I am looking for a method to load several image with Python scipt into Power BI desktop to create a dashboard. I don't want to manually select images and import them.  Here is my current code and the power bi failed to recognize the image. I am using Get Data with Python Script. Is there a way to solve this issue? Or is there any alternative detailed methods to import images with script into Power BI?

 

import pandas as pd
import json
import matplotlib.pyplot as plt 
import matplotlib.cbook as cbook


#ax=plt.gca()
with cbook.get_sample_data('D:/carapace/TableauChartDisplayTask/test.png') as image_file:
    image=plt.imread(image_file)

fig, ax = plt.subplots()
  
fig.figimage(image)
#fig.figimage(image, 10, 10, zorder = 3, alpha =.5)
  
plt.title('matplotlib.pyplot.imread() function Example', 
                                     fontweight ="bold")
plt.show()

 

 And here is the result

Eraclea_0-1655480623660.png

Thank you

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

matplotlib.pyplot.imshow — Matplotlib 3.5.2 documentation

 

import matplotlib.pyplot as plt
import matplotlib.image as img
image = img.imread('c:\\users\\xxx\\downloads\\IMG_20180323_083209.jpg')
plt.imshow(image)
plt.show()

View solution in original post

2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @Eraclea ,

 

You should use the Python visual rather than python script.

vchenwuzmsft_0-1655887458307.png

 

Best Regards

Community Support Team _ chenwu zhu

 

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

lbendlin
Super User
Super User

matplotlib.pyplot.imshow — Matplotlib 3.5.2 documentation

 

import matplotlib.pyplot as plt
import matplotlib.image as img
image = img.imread('c:\\users\\xxx\\downloads\\IMG_20180323_083209.jpg')
plt.imshow(image)
plt.show()

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.