gpt4 book ai didi

python-3.x - HTTP错误 : HTTP Error 403: urlib3 while using smopy

转载 作者:行者123 更新时间:2023-12-04 01:18:24 28 4
gpt4 key购买 nike

我试图在使用 smopy 时生成 osm 贴图,但我一直收到禁止的错误,这是代码集:

box = (lat[region].min(), lon[region].min(),
lat[region].max(), lon[region].max())
m = smopy.Map(box, z=12)
m.show_ipython()

然后我得到以下错误:

HTTPError                                 Traceback (most recent call last)
<ipython-input-48-1060c6eba6aa> in <module>
1 box = (lat[region].min(), lon[region].min(),
2 lat[region].max(), lon[region].max())
----> 3 m = smopy.Map(box, z=12)
4 m.show_ipython()
~\AppData\Roaming\Python\Python37\site-packages\smopy.py in __init__(self, *args, **kwargs)
290 self.ymin = min(self.box_tile[1], self.box_tile[3])
291 self.img = None
--> 292 self.fetch()
293
294 def to_pixels(self, lat, lon=None):

~\AppData\Roaming\Python\Python37\site-packages\smopy.py in fetch(self)
322 """Fetch the image from OSM's servers."""
323 if self.img is None:
--> 324 self.img = fetch_map(self.box_tile, self.z)
325 self.w, self.h = self.img.size
326 return self.img

~\AppData\Roaming\Python\Python37\site-packages\smopy.py in fetch_map(box, z)
63 for y in range(y0, y1 + 1):
64 px, py = TILE_SIZE * (x - x0), TILE_SIZE * (y - y0)
---> 65 img.paste(fetch_tile(x, y, z), (px, py))
66 return img
67

~\AppData\Roaming\Python\Python37\site-packages\smopy.py in fetch_tile(x, y, z)
43 """
44 url = get_url(x, y, z)
---> 45 png = BytesIO(urlopen(url).read())
46 img = Image.open(png)
47 img.load()

~\Anaconda31\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
220 else:
221 opener = _opener
--> 222 return opener.open(url, data, timeout)
223
224 def install_opener(opener):

~\Anaconda31\lib\urllib\request.py in open(self, fullurl, data, timeout)
529 for processor in self.process_response.get(protocol, []):
530 meth = getattr(processor, meth_name)
--> 531 response = meth(req, response)
532
533 return response

~\Anaconda31\lib\urllib\request.py in http_response(self, request, response)
639 if not (200 <= code < 300):
640 response = self.parent.error(
--> 641 'http', request, response, code, msg, hdrs)
642
643 return response

~\Anaconda31\lib\urllib\request.py in error(self, proto, *args)
567 if http_err:
568 args = (dict, 'default', 'http_error_default') + orig_args
--> 569 return self._call_chain(*args)
570
571 # XXX probably also want an abstract factory that knows when it makes

~\Anaconda31\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
501 for handler in handlers:
502 func = getattr(handler, meth_name)
--> 503 result = func(*args)
504 if result is not None:
505 return result

~\Anaconda31\lib\urllib\request.py in http_error_default(self, req, fp, code, msg, hdrs)
647 class HTTPDefaultErrorHandler(BaseHandler):
648 def http_error_default(self, req, fp, code, msg, hdrs):
--> 649 raise HTTPError(req.full_url, code, msg, hdrs, fp)
650
651 class HTTPRedirectHandler(BaseHandler):

之前知道代码可以完美运行,我删除了浏览器 cookie 但没有运行,我使用的是最新版本的 python 和 anaconda

最佳答案

重新安装 smopy(获取最新版本),他们已经更改了 tileserver url。那应该工作。

关于python-3.x - HTTP错误 : HTTP Error 403: urlib3 while using smopy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56412237/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com