You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows10+Python3.10下Geopy调用Nominatim遇SSL证书过期错误

问题:Windows 10 + Python 3.10环境下Geopy调用Nominatim服务遇SSL证书过期错误,ArcGIS服务正常运行

环境信息

  • 操作系统:Windows 10
  • Python版本:3.10
  • 现象:使用Geopy调用Nominatim服务时触发SSL证书验证失败错误(提示证书已过期),但调用ArcGIS服务可正常返回地理编码结果

示例代码

import certifi
import ssl

import geopy.geocoders
from geopy.geocoders import Nominatim
from geopy.geocoders import ArcGIS

ctx = ssl.create_default_context(cafile=certifi.where())
geopy.geocoders.options.default_ssl_context = ctx

print('')
print('Trying Nominatim')
try:
    geolocator_NOM = Nominatim(user_agent="NewApp314", timeout=10)
    location_NOM = geolocator_NOM.geocode('1600 Amphitheatre Parkway, Mountain View, CA')

    print(f'Location Address: {location_NOM.address}')
    print(f'Location Latitude: {location_NOM.latitude}')
    print(f'Location Longitude: {location_NOM.longitude}')
except Exception as error:
    print(f'Error in Nominatim: {error}')


print('')
print('Trying ArcGIS:')
try:
    geolocator_ARC = ArcGIS()
    location_ARC = geolocator_ARC.geocode('1600 Amphitheatre Parkway, Mountain View, CA')

    print(f'Location Address: {location_ARC.address}')
    print(f'Location Latitude: {location_ARC.latitude}')
    print(f'Location Longitude: {location_ARC.longitude}')
except Exception as error:
    print(f'Error in ArcGIS: {error}')

运行结果

Trying Nominatim:
Error in Nominatim: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /search?q=1600+Amphitheatre+Parkway%2C+Mountain+View%2C+CA&format=json&limit=1 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)')))

Trying ArcGIS:
Location Address: 1600 Amphitheatre Pkwy, Mountain View, California, 94043
Location Latitude: 37.421976010046
Location Longitude: -122.084524027111

补充说明

已查阅Stack Overflow相关问题,现有解决方案无法解决该问题。

内容的提问来源于stack exchange,提问作者Craig Evans

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 18:35:09