I'm trying to create an GUI which, on the basis of user's choice gets the lat and long of US states from a CSV file and gets the current time in that state using timezonefinder
and datetime module.
I understand that few states have 2 time zones, but getting only 1 time zone is fine for this project.
While I'm able to properly use the code and it functions perfectly as a python script, but when I convert it into an executable using pyinstaller
, I get a FileNotFound Error
.
Here is the code:
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
And here is the error I get:
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'
Please suggest how can I fix this error.
or if there is a workaround by including another library that is supported by pyinstaller
, or maybe creating an executable by something other then pyinstaller
?
I'm but a novice right now, so please suggest the best course of action.
Add this parameter to the command line when running pyinstaller:
--collect-data timezonefinder