2017-10-04 23 views
1

Python 3.6アプリケーションで[geopy][1]を使用していて、Windows 2012 Serverを使用する古いマシンで実行する必要があります。アプリケーションからこのライブラリがこのサーバーで呼び出されたときに、次のエラーが返されるため、問題が発生します。Python ssl.SSLError:証明書の検証に失敗しました(_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を実行しています。次です:

win2012SSLライブラリを古いしている可能性がある。最後に

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)) 

答えて

0

、私は解決策を持っています。

正しいコードは次のとおりです:

from geopy.geocoders import Nominatim 
from geopy.exc import GeocoderTimedOut 

def getLocation(name): 
    geolocator = Nominatim(scheme='http') 
    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)) 
ので、解決策は schemahttpであることを明示的に示すことです
関連する問題