Hi everyone,
I’m currently running a Python script from UiPath using the Invoke Python Method activity. The script uses Prophet to forecast top 5 sender IDs based on Excel data, and it successfully creates and saves the result to a local Excel file.
The output file is saved correctly, so the script works.
But in UiPath, the process never ends — it just keeps “running” after calling the Python method, without error and without moving forward to the next activity.
Here’s what I’ve tried:
- Using Load Python Script → Invoke Python Method
- The Python function returns
"done"
at the end - No
input()
orplot.show()
is used - The script runs fine in VSCode/terminal
- No exceptions are thrown
my code :
import pandas as pd
from prophet import Prophet
import warnings
warnings.filterwarnings(“ignore”)
def forecast_top5_senderid_june_2025(excel_path):
df = pd.read_excel(excel_path, sheet_name=“CleanedData”)
df[“tanggal”] = pd.to_datetime(df[“tanggal”])
df = df[(df[“tanggal”] >= “2025-01-01”) & (df[“tanggal”] <= “2025-05-31”)]
results = []
for sid in df["sender_id"].unique():
sid_df = df[df["sender_id"] == sid].copy()
ts_df = sid_df.groupby("tanggal")["total_transaksi"].sum().reset_index()
ts_df.columns = ["ds", "y"]
if len(ts_df) < 15:
continue
try:
model = Prophet()
model.fit(ts_df)
future = model.make_future_dataframe(periods=30, freq='D')
forecast = model.predict(future)
june_forecast = forecast[(forecast["ds"].dt.month == 6) & (forecast["ds"].dt.year == 2025)]
total_june = june_forecast["yhat"].sum()
results.append((sid, total_june))
except Exception:
continue
result_df = pd.DataFrame(results, columns=["sender_id", "total_forecast_june_2025"])
top5 = result_df.sort_values(by="total_forecast_june_2025", ascending=False).head(5)
top5["total_forecast_june_2025"] = top5["total_forecast_june_2025"].round().astype(int)
# Output file is created correctly
save_path = r"your\output\path\here\hasil_forecast_june_2025.xlsx"
top5.to_excel(save_path, index=False)
return "done"
Has anyone faced this kind of issue where Invoke Python Method
never completes even though the script itself has finished and the output file is already created?
Would really appreciate any help or insight
Thanks in advance!