![](/img/trans.png)
[英]Pyinstaller and --onefile: How to include an image in the exe file
[英]How to include timzonefinder module while creating an exe file via pyinstaller
我正在尝试创建一个 GUI,它根据用户的选择从 CSV 文件中获取美国各州的纬度和经度,并使用timezonefinder
和 datetime 模块获取该 state 中的当前时间。
我知道很少有州有 2 个时区,但只有 1 个时区对这个项目来说很好。 虽然我能够正确使用代码并且它作为 python 脚本完美运行,但是当我使用pyinstaller
将它转换为可执行文件时,我得到了FileNotFound Error
。
这是代码:
import pandas
from tkinter import *
from tkinter import messagebox
from datetime import datetime
from timezonefinder import TimezoneFinder
import pytz
def get_time(state_choosen):
tf = TimezoneFinder()
states_data = pandas.read_csv('data/us_states.csv')
data_list = states_data.to_dict('records')
for data in data_list:
if state_choosen == data['state']:
longitude = data['longitude']
latitude = data['latitude']
t_zone = tf.timezone_at(lng=longitude, lat=latitude)
tzone = pytz.timezone(t_zone)
current_time = datetime.now(tz=tzone).strftime("%I:%M:%S %p")
return current_time
这是我得到的错误:
Traceback (most recent call last):
File "tkinter\__init__.py", line 1892, in __call__
File "main.py", line 179, in city_time
current_time = us_time.get_time(city)
File "us_time.py", line 10, in get_time
tf = TimezoneFinder()
File "timezonefinder\timezonefinder.py", line 260, in __init__
File "timezonefinder\timezonefinder.py", line 118, in __init__
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\vaibhav\\AppData\\Local\\Temp\\_MEI71562\\timezonefinder\\poly_zone_ids.bin'
请建议我如何解决此错误。 或者是否有解决方法,包括 pyinstaller 支持的另一个库,或者可能通过pyinstaller
pyinstaller
东西创建可执行文件?
我现在只是一个新手,所以请建议最好的行动方案。
运行pyinstaller时在命令行添加这个参数:
--collect-data timezonefinder
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.