【发布时间】:2023-03-16 16:16:01
【问题描述】:
我正在使用 gmplot 在谷歌地图上绘制标记。在使用 pyinstaller 制作 exe 文件之前一切正常。我无法执行 gmp.draw 将标记绘制到我的 map.html 中。执行 pyinstaller 时没有显示错误。 当我执行我的exe文件时,错误显示
Exception in Tkinter callback
Traceback (most recent call last):
File "tkinter\__init__.py", line 1705, in __call__
File "test.py", line 792, in plotmap
gmap.draw('map.html')
File "site-packages\gmplot\gmplot.py", line 1050, in draw
File "site-packages\gmplot\gmplot.py", line 1121, in _write_html
File "site-packages\gmplot\gmplot.py", line 1187, in write_points
File "site-packages\gmplot\gmplot.py", line 1228, in write_point
File "site-packages\gmplot\gmplot.py", line 164, in __init__
File "site-packages\gmplot\utility.py", line 68, in _get_embeddable_image
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Admin\\AppData\\Local\\Temp\\_MEI366362\\gmplot\\markers/000000.png'
我尝试通过添加来修复它
gmp.coloricon = "http://www.googlemapsmarkers.com/v1/%s/"
但没有任何改变。
这是我关于 gmplot 的代码
import gmplot
import webbrowser
from tkinter import *
import tkinter as tk
def plotmap():
# Create the map plotter:
apikey = '' # (your API key here)
gmap = gmplot.GoogleMapPlotter(37.766956, -122.448481, 14, apikey=apikey)
# Outline the Golden Gate Park:
golden_gate_park = zip(*[
(37.771269, -122.511015),
(37.773495, -122.464830),
(37.774797, -122.454538),
(37.771988, -122.454018),
(37.773646, -122.440979),
(37.772742, -122.440797),
(37.771096, -122.453889),
(37.768669, -122.453518),
(37.766227, -122.460213),
(37.764028, -122.510347)
])
gmap.polygon(*golden_gate_park, color='cornflowerblue', edge_width=10)
# Highlight some attractions:
attractions_lats, attractions_lngs = zip(*[
(37.769901, -122.498331),
(37.768645, -122.475328),
(37.771478, -122.468677),
(37.769867, -122.466102),
(37.767187, -122.467496),
(37.770104, -122.470436)
])
gmap.scatter(attractions_lats, attractions_lngs, color='#3B0B39', size=40, marker=False)
# Mark a hidden gem:
gmap.marker(37.770776, -122.461689, color='cornflowerblue')
# Draw the map:
gmap.draw('map.html')
webbrowser.open('map.html')
root = tk.Tk()
b = tk.Button(root, text= "plot on map", command=plotmap)
b.pack()
root.mainloop()
【问题讨论】:
标签: python google-maps-markers pyinstaller markers gmplot