Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

How load image in python on online report

Hi,

 

I am want to add a background image to a scatter plot and the only way I could think of is doing it in python, here is the python code:

 

# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:

# dataset = pandas.DataFrame(x, z)
# dataset = dataset.drop_duplicates()

# Paste or type your script code here:
import numpy as np
import matplotlib.pyplot as plt

ax = plt.gca()
image_path = '<Image_URL>'
image = plt.imread(image_path)
ax.imshow(image, extent=[-150, 157, -150, 145])

posx = dataset.x
posz = dataset.z
plt.scatter(posx, posz, color='red', s=0.8)
plt.show()

 

My image I want to use is in an Azure blob storage and I create a shared access signature to access it, it works fine on the desktop app but when I publish it online I get this error:

Script Runtime Error

File "C:\Python\Lib\http\client.py", line 1298, in _send_request

self.endheaders(body, encode_chunked=encode_chunked)

File "C:\Python\Lib\http\client.py", line 1247, in endheaders

self._send_output(message_body, encode_chunked=encode_chunked)

File "C:\Python\Lib\http\client.py", line 1026, in _send_output

self.send(msg)

File "C:\Python\Lib\http\client.py", line 966, in send

self.connect()

File "C:\Python\Lib\http\client.py", line 1414, in connect

super().connect()

File "C:\Python\Lib\http\client.py", line 938, in connect

(self.host,self.port), self.timeout, self.source_address)

File "C:\Python\Lib\socket.py", line 707, in create_connection

for res in getaddrinfo(host, port, 0, SOCK_STREAM):

File "C:\Python\Lib\socket.py", line 752, in getaddrinfo

for res in _socket.getaddrinfo(host, port, family, type, proto, flags):

socket.gaierror: [Errno 11001] getaddrinfo failed

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

File "C:\Script\0.py", line 32, in <module>

image = plt.imread(image_path)

File "C:\Python\lib\site-packages\matplotlib\pyplot.py", line 2061, in imread

return matplotlib.image.imread(fname, format)

File "C:\Python\lib\site-packages\matplotlib\image.py", line 1472, in imread

fd = BytesIO(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 1362, in https_open

context=self._context, check_hostname=self._check_hostname)

File "C:\Python\Lib\urllib\request.py", line 1321, 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.
Activity ID: 4e7b3908-0bf8-4531-add8-f6db64126774
Request ID: a3eb5f20-a82f-d992-6e98-3a31bc514bd3
Correlation ID: 863a9f65-6020-cdf3-448d-652bdd0d974b
Time: Tue Aug 04 2020 18:03:25 GMT+0100 (British Summer Time)
Service version: 13.0.13960.55
Client version: 2007.3.02181-train
Cluster URI: https://wabi-uk-south-b-primary-redirect.analysis.windows.net/

1 Reply

  • v-xuding-msft's avatar
    v-xuding-msft
    Community Support

    Hi Anonymous ,

     

    Please check if your personal gateway is working and your credential is correct.