在 Jupyter Notebook 中使用 Nominatim 时出现 ConfigurationError

ConfigurationError While using Nominatim in Jupyter Notebook

我最近下载了 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 上尝试了同样的操作,但收到了同样的错误。还尝试四处搜索,但似乎找不到与我的问题有关的任何内容。非常感谢您的帮助。谢谢

请确保使用 Nominatim(user_agent="my-application") 或覆盖默认 user_agent 指定自定义 user_agent,因为您没有指定相同的内容:

geopy.geocoders.options.default_user_agent = "my-application".

如果未指定自定义user_agent,将抛出异常。