![](/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.