1
我在一家Python 3.6
應用程序中使用[geopy][1]
,我不得不使用Windows 2012 Server
一個過時的機器上運行它。問題出現時,從應用這個庫稱爲此服務器上,因爲它返回以下錯誤:的Python ssl.SSLError:SSL:CERTIFICATE_VERIFY_FAILED]證書驗證失敗(_ssl.c:748)
File "C:\ServAPI\Util.py", line 12, in getLocation
location = geolocator.geocode(name)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\geopy\geocoders\osm.py", line 193, in geocode
self._call_geocoder(url, timeout=timeout), exactly_one
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\geopy\geocoders\base.py", line 171, in _call_geocoder
raise GeocoderServiceError(message)
geopy.exc.GeocoderServiceError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)
我怎樣才能解決這個問題?我對Windows 2012 Server
UPDATE
的代碼運行Python 3.6.0
是下一個:
from geopy.geocoders import Nominatim
from geopy.exc import GeocoderTimedOut
def getLocation(name):
geolocator = Nominatim()
try:
location = geolocator.geocode(name, timeout=5)
return location
except GeocoderTimedOut as e:
print("Error: geocode failed on input %s with message %s" % (e.msg))