【问题标题】:KeyError Traceback (most recent call last)KeyError Traceback(最近一次调用最后一次)
【发布时间】:2021-04-17 02:17:41
【问题描述】:
**from geopy.geocoders import Here
    exif = get_exif('earth_postcard_1599147372.jpg')
    geotags = get_geotagging(exif)
    coords = get_coordinates(geotags)
    geocoder = Here(apikey=os.environ['API_KEY'])
    print(geocoder.reverse("%s,%s" % coords))**



ERROR
KeyError                                  Traceback (most recent call last)
<ipython-input-13-baa26ae24e59> in <module>
      4 geotags = get_geotagging(exif)
      5 coords = get_coordinates(geotags)
----> 6 geocoder = Here(apikey=os.environ['API_KEY'])
      7 print(geocoder.reverse("%s,%s" % coords))

~\anaconda3\lib\os.py in __getitem__(self, key)
    677         except KeyError:
    678             # raise KeyError with the original key value
--> 679             raise KeyError(key) from None
    680         return self.decodevalue(value)
    681 

KeyError: 'API_KEY'

在这里我尝试使用 geopy 库获取使用纬度和对数的位置,但我得到关键错误

【问题讨论】:

    标签: python exif geopy


    【解决方案1】:

    你应该检查你是否设置了你的环境参数。你可以进入python命令行模式然后输入:

    导入操作系统
    os.environ.keys()

    系统将输出所有环境参数。“API_KEY”不应设置。如果你在系统参数列表中设置了这个键,这个错误就会消失。

    【讨论】:

      猜你喜欢
      • 2021-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-19
      • 2020-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多