我有一个地址列表,当我尝试添加坐标时,我只会得到一个kill9错误。你知道吗
是不是超时了?我增加了睡眠时间来防止它。你知道吗
我得到这个错误Killed: 9
def do_geocode(Nominatim, address):
time.sleep(3)
try:
return Nominatim.geocode(address)
except GeocoderTimedOut:
return do_geocode(Nominatim,address)
def addCoordinates(businessList):
businessList[0] = ["pageNum","entryNum","name","address","tagOne","tagTwo","tagThree","geoAddress","appendedLocation","latitude","longitude","key"]
geolocator = Nominatim(timeout=None)
z = 0
i=1
while i < len(businessList):
longitude = ""
latitude = ""
geoLocation = ""
geoAddress = ""
entry = []
appendedLocation = (businessList[i][3] + ", San Francisco")
geoLocation = do_geocode(geolocator, appendedLocation)
if geoLocation is not None:
geoAddress = geoLocation.address
latitude = geoLocation.latitude
longitude = geoLocation.longitude
entry = [geoAddress, appendedLocation, str(latitude), str(longitude)]
j=0
while j < len(entry):
businessList[i] += [entry[j]]
j+=1
print("coordinates added")
z +=1
print(z)
i+=1
Killed: 9
可能意味着您的Python脚本已被操作系统中的某个东西终止(可能是OOM killer?)。确保脚本不会占用计算机的全部可用内存。你知道吗对于geopy,我建议看一下RateLimiter类。还要注意,在使用namignim时,需要指定唯一的用户代理(这在the Nominatim class docs中进行了解释)。你会得到这样的结果:
相关问题 更多 >
编程相关推荐