【发布时间】:2018-03-15 13:38:57
【问题描述】:
我在Python 3.6 应用程序中使用[geopy][1],我必须在使用Windows 2012 Server 的过时机器上运行它。当从应用程序在此服务器上调用此库时会出现问题,因为它返回以下错误:
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 上运行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))
【问题讨论】:
标签: python windows python-3.x ssl geolocation