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
michaelstone
Helper I
Helper I

Error when running Python Visualisation Script in Power BI Service

Hi all,

I have built a Python visualisation script in Power BI Desktop which performs the following steps:

  • Accepts an URL for an image in the dataset dataframe
  • Retrieves the image from the external URL via an image reformatting service called rethumb.com
  • Modifies the image
  • Displays the image within the visualisation

This works perfectly in Power BI Desktop but when I upload the PBIX to Power BI Service I get the following error.

 Traceback (most recent call last):
 
 File "C:\Script\0.py", line 35, in <module>
 
 img = mpimg.imread('https://api.rethumb.com/v1/width/900/format/png/'+dataset.iloc[0].R_CoverImage)
 
 File "C:\Python\lib\site-packages\matplotlib\image.py", line 1363, in imread
 
 fd = BytesIO(urllib.request.urlopen(fname).read())
 
 File "C:\Python\Lib\urllib\request.py", line 222, in urlopen
 
 return opener.open(url, data, timeout)
 
 File "C:\Python\Lib\urllib\request.py", line 525, in open
 
 response = self._open(req, data)
 
 File "C:\Python\Lib\urllib\request.py", line 543, in _open
 
 '_open', req)
 
 File "C:\Python\Lib\urllib\request.py", line 503, in _call_chain
 
 result = func(*args)
 
 File "C:\Python\Lib\urllib\request.py", line 1360, in https_open
 
 context=self._context, check_hostname=self._check_hostname)
 
 File "C:\Python\Lib\urllib\request.py", line 1319, in do_open
 
 raise URLError(err)
 
 urllib.error.URLError: <urlopen error [Errno 11001] getaddrinfo failed>
 
 
Please try again later or contact support. If you contact support, please provide these details.

My Google searches suggest that the error is caused by the hostname not being resolved so I'm guessing that the scripting engine within Power BI service does not have access to a DNS to complete the request.

 

Can anyone confirm this or suggest a walkaround?

 

Thanks,

 

Michael

 

4 REPLIES 4
gonzalovaca
New Member

I am needing to do the same. It is been 2 years. Is there anyway to visualize an image from an external website?

 

import matplotlib.pyplot as plt
import matplotlib.image as mpimg

img = 'https://storage.googleapis.com/xxxxxxx/xxxxxx.svg.png'
img = mpimg.imread(img)
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
plt.show()

This works in PowerBI desktop, but not as powerBi service ?

Is it possible to do it from a network drive or local drive? please give some guidance.

 

Thanks!

 

Andy_T
Frequent Visitor

Hi, did you have any luck with this? I can't get imread or imshow to work in the service.

No.

 

Worked through with support but unfortuanately the Python functionality is sandboxed to restrict access to external content.

 

We are now using the Simple Image visualisation and overlay a Python visualisation on top to achieve the desired outcome.

 

Cheers,

 

Michael

v-lili6-msft
Community Support
Community Support

HI, @michaelstone 

For your case, I would suggest you create a support ticket here to get further help.

Go to https://support.powerbi.com. Scroll down and click "CREATE SUPPORT TICKET".
 

submit a support ticketsubmit a support ticket

https://community.powerbi.com/t5/Community-Blog/How-to-create-a-support-ticket-in-Power-BI/ba-p/6830...

 

Best Regards,

Lin

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

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.

Top Solution Authors
Top Kudoed Authors