Observe the simple reproducible example at the end of the post . It works just fine when running it with
uv run --with pandas==2.3.3 --with numpy==2.4.4 --with plotly==6.7.0 --with kaleido==1.2.0 generate_plot_png.py
TypeError: Type is not JSON serializable: Timestamp
uv run --with pandas==2.3.3 --with numpy==2.4.4 --with plotly==6.7.0 --with kaleido==1.3.0 generate_plot_png.py
import numpy as np
import pandas as pd
import plotly.graph_objects as go
def generate_dataframe() -> pd.DataFrame:
rng = np.random.default_rng(42)
index = pd.bdate_range("2026-01-30", "2026-06-03")
data = {
"col_1": np.round(rng.uniform(10.0, 30.0, len(index))),
"col_2": np.round(rng.uniform(1.0, 30.0, len(index))),
"col_3": np.round(rng.uniform(20.0, 50.0, len(index))),
"col_4": np.round(rng.uniform(4.0, 100.0, len(index))),
"col_5": np.round(rng.uniform(30.0, 40.0, len(index))),
}
df = pd.DataFrame(data, index=index).astype("float64")
df.index = df.index.astype("datetime64[ns]")
return df
df = generate_dataframe()
fig = go.Figure()
for c in df.columns:
fig.add_trace(
go.Scatter(
x=df.index,
y=df[c],
name=c,
mode="lines",
)
)
# Last point marker + label
# SOMETHING HERE MAKES IT FAIL
last_idx = df[c].last_valid_index()
if last_idx is not None:
last_val = df.loc[last_idx, c]
fig.add_trace(
go.Scatter(
x=[last_idx],
y=[last_val],
mode="markers",
showlegend=False,
hoverinfo="skip",
)
)
fig.write_image("plot1.png")
Observe the simple reproducible example at the end of the post . It works just fine when running it with
When I run the same script but with
kaleido==1.3.0, it raises an exception.Command:
Code: