我有这个代码,它生成一个带有folium的webmap,它会读取一些文件并在地图上绘制一些线条。
我想与一群对python一无所知的人分享我的程序,所以我想创建一个.exe文件。 我使用最新的pyinstaller开发版本在python 3.6.1上,但是当我尝试运行exe文件时出现错误。
NotImplementedError:无法对未注册的加载程序类型执行此操作 无法执行脚本map_generator
有人知道我该怎么办?这可能是其他任何包装吗?
谢谢大家
import folium
import pandas
from fastkml import kml
def get_group(elev):
if elev in range(0,1000):
group = cero
elif elev in range(1000,2000):
group = mil
elif elev in range(2000,3000):
group = dosmil
elif elev in range(3000,4000):
group = tresmil
elif elev in range(4000,5000):
group = cuatromil
elif elev in range(5000,6000):
group = cincomil
elif elev in range(6000,7000):
group = seismil
elif elev in range(7000,8000):
group = sietemil
elif elev in range(8000,9000):
group = ochomil
elif elev in range(9000,10000):
group = nuevemil
elif elev in range(10000,11000):
group = diezmil
elif elev in range(11000,12000):
group = oncemil
elif elev in range(12000,13000):
group = docemil
elif elev in range(13000,14000):
group = trecemil
elif elev in range(14000,15000):
group = catorcemil
elif elev in range(15000,16000):
group = quincemil
elif elev in range(16000,17000):
group = dieciseismil
elif elev in range(17000,18000):
group = diecisietemil
elif elev in range(18000,19000):
group = dieciochomil
elif elev in range(19000,20000):
group = diecinuevemil
else:
group = veintemil
return group
def colorear(elev):
if elev in range(0,1000):
color = '#5d005e'
elif elev in range(1000,2000):
color = '#950096'
elif elev in range(2000,3000):
color = '#fd00ff'
elif elev in range(3000,4000):
color = '#16005c'
elif elev in range(4000,5000):
color = '#240198'
elif elev in range(5000,6000):
color = '#4f21e3'
elif elev in range(6000,7000):
color = '#06334f'
elif elev in range(7000,8000):
color = '#115e8d'
elif elev in range(8000,9000):
color = '#28aeff'
elif elev in range(9000,10000):
color = '#045e45'
elif elev in range(10000,11000):
color = '#299c7d'
elif elev in range(11000,12000):
color = '#083c00'
elif elev in range(12000,13000):
color = '#128700'
elif elev in range(13000,14000):
color = '#359826'
elif elev in range(14000,15000):
color = '#33fd14'
elif elev in range(15000,16000):
color = '#777e07'
elif elev in range(16000,17000):
color = '#c0cc06'
elif elev in range(17000,18000):
color = '#eaf62a'
elif elev in range(18000,19000):
color = '#ff8100'
elif elev in range(19000,20000):
color = '#b00000'
else:
color = '#ff2e2e'
return color
map = folium.Map(location=[-13.537638,-71.943920], zoom_start=6, tiles='Stamen Terrain', control_scale=True)
cero = folium.FeatureGroup(name = '0 ft')
mil = folium.FeatureGroup(name = '1000 ft')
dosmil = folium.FeatureGroup(name = '2000 ft')
tresmil = folium.FeatureGroup(name = '3000 ft')
cuatromil = folium.FeatureGroup(name = '4000 ft')
cincomil = folium.FeatureGroup(name = '5000 ft')
seismil = folium.FeatureGroup(name = '6000 ft')
sietemil = folium.FeatureGroup(name = '7000 ft')
ochomil = folium.FeatureGroup(name = '8000 ft')
nuevemil = folium.FeatureGroup(name = '9000 ft')
diezmil = folium.FeatureGroup(name = '10000 ft')
oncemil = folium.FeatureGroup(name = '11000 ft')
docemil = folium.FeatureGroup(name = '12000 ft')
trecemil = folium.FeatureGroup(name = '13000 ft')
catorcemil = folium.FeatureGroup(name = '14000 ft')
quincemil = folium.FeatureGroup(name = '15000 ft')
dieciseismil = folium.FeatureGroup(name = '16000 ft')
diecisietemil = folium.FeatureGroup(name = '17000 ft')
dieciochomil = folium.FeatureGroup(name = '18000 ft')
diecinuevemil = folium.FeatureGroup(name = '19000 ft')
veintemil = folium.FeatureGroup(name = '20000 ft')
ruta = folium.FeatureGroup(name = 'ruta')
k = kml.KML()
k.from_string(open("ruta.kml").read())
features = list(k.features())
folders = list(features[0].features())
placemarks = list(folders[0].features())
coordenadas_ruta = placemarks[0].geometry.coords
flight_path = list()
for coordenada in coordenadas_ruta:
coor = (coordenada[1],coordenada[0])
flight_path.append(coor)
ruta.add_child(folium.PolyLine(locations = flight_path))
geojson = pandas.read_json('topo.geojson')
for linea in geojson['features']:
grupo = get_group(int(linea['properties']['ELEVATION'][:linea['properties']['ELEVATION'].find(' ')]))
coors = linea['geometry']['coordinates']
(folium.PolyLine(locations=coors,latlon=False, weight=6,color=colorear(int(linea['properties']['ELEVATION'][:linea['properties']['ELEVATION'].find(' ')])))).add_to(grupo)
m = pandas.read_csv('picos.csv')
for id,altitud,latitud,longitud in zip(m['ID'],m['ALT'],m['LAT'],m['LON']):
grupo = get_group(altitud)
folium.RegularPolygonMarker(location=[latitud,longitud], popup=folium.Popup(str(altitud)+' ft'),
fill_color=colorear(altitud), number_of_sides=3, radius=10).add_to(grupo)
map.add_child(cero)
map.add_child(mil)
map.add_child(dosmil)
map.add_child(tresmil)
map.add_child(cuatromil)
map.add_child(cincomil)
map.add_child(seismil)
map.add_child(sietemil)
map.add_child(ochomil)
map.add_child(nuevemil)
map.add_child(diezmil)
map.add_child(oncemil)
map.add_child(docemil)
map.add_child(trecemil)
map.add_child(catorcemil)
map.add_child(quincemil)
map.add_child(dieciseismil)
map.add_child(diecisietemil)
map.add_child(dieciochomil)
map.add_child(diecinuevemil)
map.add_child(veintemil)
map.add_child(ruta)
map.add_child(folium.LayerControl())
map.save('mapa.html')
答案 0 :(得分:0)
尝试在包含代码的目录中添加名为(billInfo != null && !string.IsNullOrEmpty(billInfo.BillingMethod) || (bill != null && !billInfo.BillingMethod?.Equals(bill))
的空文件。这允许Python将您的目录视为包。