Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
265 views
in Technique[技术] by (71.8m points)

python - ConfigurationError While using Nominatim in Jupyter Notebook

I recently downloaded geopy and tested it out on Jupyter's notebook with the code below.

import geopy
from geopy.geocoders import Nominatim
nom=Nominatim(scheme="http")

After running this I received the following error:

---------------------------------------------------------------------------
ConfigurationError                        Traceback (most recent call last)
<ipython-input-50-899501bc88f0> in <module>
----> 1 nom=Nominatim(scheme="http")

c:usersabhilash guptaappdatalocalprogramspythonpython39libsite-packagesgeopygeocoders
ominatim.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"`.

I tried the same thing on Pycharm and received the same error. Also tried searching around but couldn't seem to find anything pertaining to my problem. Would appreciate the help. Thanks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

kindly make sure to specify a custom user_agent with Nominatim(user_agent="my-application") or by overriding the default user_agent as you have not specified the same :

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

An exception will be thrown if a custom user_agent is not specified.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...