我最近下载了geopy,并用下面的代码在Jupyter的笔记本上进行了测试
import geopy
from geopy.geocoders import Nominatim
nom=Nominatim(scheme="http")
运行此命令后,我收到以下错误:
---------------------------------------------------------------------------
ConfigurationError Traceback (most recent call last)
<ipython-input-50-899501bc88f0> in <module>
----> 1 nom=Nominatim(scheme="http")
c:\users\abhilash gupta\appdata\local\programs\python\python39\lib\site-packages\geopy\geocoders\nominatim.py in __init__(self, timeout, proxies, domain, scheme, user_agent, ssl_context, adapter_factory)
103 if (self.domain == _DEFAULT_NOMINATIM_DOMAIN
104 and self.headers['User-Agent'] in _REJECTED_USER_AGENTS):
--> 105 raise ConfigurationError(
106 'Using Nominatim with default or sample `user_agent` "%s" is '
107 'strongly discouraged, as it violates Nominatim\'s ToS '
ConfigurationError: Using Nominatim with default or sample `user_agent` "geopy/2.1.0" is strongly discouraged, as it violates Nominatim's ToS https://operations.osmfoundation.org/policies/nominatim/ and may possibly cause 403 and 429 HTTP errors. Please specify a custom `user_agent` with `Nominatim(user_agent="my-application")` or by overriding the default `user_agent`: `geopy.geocoders.options.default_user_agent = "my-application"`.
我在Pycharm上尝试了同样的方法,但收到了同样的错误。我也试着四处搜索,但似乎找不到任何与我的问题有关的东西。谢谢你的帮助。谢谢
请确保使用namignm(user\u agent=“my application”)指定自定义用户\u代理,或覆盖默认用户\u代理,因为您尚未指定相同的用户\u代理:
如果未指定自定义用户\u代理,将引发异常
相关问题 更多 >
编程相关推荐