Hello, Iโm glad to write my problem
I wrote a code to create a static image using plotly4.
When I first started it, it stopped for a long time, then I clicked yes to add it to the whitelist in the Windows Defender notification and it worked.
After that, the Windows defender notification does not appear when running, and it runs after 3 seconds of pause.
However, the first time I run this code after turning on the computer, it always hangs. so, I had to close it.
After that it works fine again. Is it a firewall issue?? It has already been added to the allow rule.
Exception in thread Thread-10:
Traceback (most recent call last):
File โC:\Anaconda3\envs\coralMax\lib\site-packages\requests\models.pyโ, line 382, in prepare_url
scheme, auth, host, port, path, query, fragment = parse_url(url)
File โC:\Anaconda3\envs\coralMax\lib\site-packages\urllib3\util\url.pyโ, line 394, in parse_url
return six.raise_from(LocationParseError(source_url), None)
File โโ, line 3, in raise_from
urllib3.exceptions.LocationParseError: Failed to parse: http://localhost:None/
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File โC:\Anaconda3\envs\coralMax\lib\site-packages\plotly\io_orca.pyโ, line 1561, in to_image
response = request_image_with_retrying(
File โC:\Anaconda3\envs\coralMax\lib\site-packages\retrying.pyโ, line 49, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File โC:\Anaconda3\envs\coralMax\lib\site-packages\retrying.pyโ, line 212, in call
raise attempt.get()
File โC:\Anaconda3\envs\coralMax\lib\site-packages\retrying.pyโ, line 247, in get
six.reraise(self.value[0], self.value[1], self.value[2])
File โC:\Anaconda3\envs\coralMax\lib\site-packages\six.pyโ, line 703, in reraise
raise value
File โC:\Anaconda3\envs\coralMax\lib\site-packages\retrying.pyโ, line 200, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File โC:\Anaconda3\envs\coralMax\lib\site-packages\plotly\io_orca.pyโ, line 1471, in request_image_with_retrying
response = post(server_url + โ/โ, data=json_str)
File โC:\Anaconda3\envs\coralMax\lib\site-packages\requests\api.pyโ, line 119, in post
return request(โpostโ, url, data=data, json=json, **kwargs)
File โC:\Anaconda3\envs\coralMax\lib\site-packages\requests\api.pyโ, line 61, in request
return session.request(method=method, url=url, **kwargs)
File โC:\Anaconda3\envs\coralMax\lib\site-packages\requests\sessions.pyโ, line 528, in request
prep = self.prepare_request(req)
File โC:\Anaconda3\envs\coralMax\lib\site-packages\requests\sessions.pyโ, line 456, in prepare_request
p.prepare(
File โC:\Anaconda3\envs\coralMax\lib\site-packages\requests\models.pyโ, line 316, in prepare
self.prepare_url(url, params)
File โC:\Anaconda3\envs\coralMax\lib\site-packages\requests\models.pyโ, line 384, in prepare_url
raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: http://localhost:None/
This is my code
def get_Image(my_lat, my_lon, heading, WP_Info):
WP_lon = []
WP_lat = []
WP_num = tuple(WP_Info.keys()) #way point
for index in WP_num:
WP_lon.append(WP_Info[index]['lon'])
WP_lat.append(WP_Info[index]['lat'])
fig = go.Figure(go.Scattermapbox(
mode = "lines", # "markers+lines",
lon = WP_lon,
lat = WP_lat,
opacity = 0.5,
line=go.scattermapbox.Line(
color = '#0EFDFE',
width=6
)
))
fig.update_layout(
margin ={'l':0,'t':0,'b':0,'r':0},
mapbox = {
'center': {'lon': my_lon, 'lat': my_lat},
'style': "white-bg",
'zoom': 20})
fig.update_mapboxes(bearing=heading)
img_bytes = fig.to_image(format="png", width=1749, height=966/2, scale=1,engine = 'orca' )
return img_bytes
}
I found something in the last line.
fig.to_image(format="png", width=1749, height=966/2, scale=1,engine = 'orca' )
if I remove 'engine = โorcaโ , it work out
but I need โorcaโ because this is fast