运行python脚本从Google静态地图图像获取像素点时出错。我从Google maps - how to get building's polygon coordinates from address? 我使用python2.7当我运行该脚本我没有得到任何错误执行脚本 最初python脚本,但连续运行3-4小时后,我收到以下错误连续执行脚本时出现python脚本库错误
Traceback (most recent call last):
File "pyscript.py", line 19, in <module>
imgBuildings = io.imread(urlBuildings)
File "/usr/local/lib/python2.7/dist-packages/skimage/io/_io.py", line 60, in i
with file_or_url_context(fname) as fname:
File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/dist-packages/skimage/io/util.py", line 29, in
u = urlopen(resource_name)
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 435, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 473, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden
因为我是新来的蟒蛇我不知道如何解决它?这是一种缓存问题吗? 非常感谢帮助。
我在处理从外部源下载的地理位置数据时最近发现了很多。该代码不够灵活,无法处理所需的下载问题。你必须把代码放在一个尝试中,除非在一天中有这么一个机会,你会得到一个网络丢失并丢失一些数据包。这很可能是所有正在发生的事情。在这种情况下,urllib2下载会返回一个异常。所以那是你所看到的错误。 –