**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库来获取使用纬度和对数的位置,但我得到了关键错误
发布于 2021-04-17 11:08:19
您应该检查是否已经设置了您的环境,parameter.You可以进入python命令行模式,然后输入:
导入操作系统
os.environ.keys()
系统将输出所有环境参数,不能设置API_KEY。如果在系统参数列表中设置该键,则该错误将消失。
https://stackoverflow.com/questions/67134095
复制相似问题