I’m encountering an issue when running my Python script, which uses the AutoTS library, after converting it into an executable using PyInstaller. The script works perfectly in Python, but when I run the executable, I get the following error message:
Error running AutoTSmodel: "Evaluation Metrics are missing and all models have failed, by an error in template or metrics.
There are many possible causes for this, bad parameters, environment, or an unreported bug.
Usually this means you are missing required packages for the models like fbprophet or gluonts,
or that the models in model_list are inappropriate for your data.
A new starting template may also help. KeyError('smape')"
Here’s a simplified version of my code:
import tkinter as tk
from tkinter import filedialog, messagebox
import pandas as pd
from autots import AutoTS
import logging
logging.basicConfig(filename="app.log", level=logging.DEBUG, format='%(asctime)s %(message)s')
class App:
def __init__(self, master):
self.master = master
# Initialization and UI setup code...
def load_excel_file(self):
# Code to load Excel file...
def run_autots_model(self):
try:
df = pd.read_excel(self.file_path)
date_col = next((col for col in df.columns if col.lower() in ['datum', 'date', 'ds']), None)
if date_col is None:
raise ValueError("No valid date column found.")
df[date_col] = pd.to_datetime(df[date_col])
df_clean = df.dropna()
self.final_forecast = pd.DataFrame()
for col in df_clean.columns[1:]:
model = AutoTS(
forecast_length=12,
frequency='infer',
prediction_interval=0.9,
ensemble='simple',
model_list="superfast",
transformer_list="superfast",
drop_most_recent=1,
validation_method='seasonal 168',
max_generations=5,
num_validations=2,
model_interrupt=True,
n_jobs='3',
)
model.fit(df_clean, date_col=date_col, value_col=col)
forecast = model.predict()
forecast_df = forecast.forecast.reset_index(drop=False)
forecast_df.rename(columns={'index': 'Datum', 'forecast': col}, inplace=True)
if self.final_forecast.empty:
self.final_forecast = forecast_df
else:
self.final_forecast = self.final_forecast.merge(forecast_df, on='Datum', how='outer')
# Code to display forecast...
except Exception as e:
logging.error("Error running AutoTSmodel: %s", str(e))
messagebox.showerror("Error", f"Error running AutoTS model: {str(e)}")
def save_forecast(self):
# Code to save forecast...
if __name__ == "__main__":
root = tk.Tk()
app = App(root)
root.mainloop()
What I’ve Tried:
- Ensured all dependencies are included: I’ve tried specifying hidden imports in the PyInstaller spec file for fbprophet and gluonts, but the issue persists.
- Checked for missing files: I’ve verified that all necessary files are bundled with the executable.
Questions:
- Are there any specific dependencies or files that need to be included when using PyInstaller with AutoTS?
- Could the issue be related to how PyInstaller handles the environment or the packages?
- Is there a way to debug or diagnose this issue more effectively?
Any guidance on resolving this would be greatly appreciated
New contributor
Philip Bui is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.