当前位置: 首页 > 工具软件 > geopy > 使用案例 >

geopy 库 ConfigurationError 错误

凌蕴藉
2023-12-01

错误详情

geopy.exc.ConfigurationError: 
Using Nominatim with default or sample `user_agent` "geopy/2.2.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"`.

解决办法

这个错误是因为这个 UA 默认值被用烂了,随便指定 user-agent 为一个 unique 的字符串就行,比如 BuyiXiao
初始化 Nominatim 时指定 user-agent

geolocator = Nominatim(user_agent='BuyiXiao')
 类似资料: