Skip to content

UserWarning: Message serialization failed with: Out of range float values are not JSON compliant #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
antonioalegria opened this issue Apr 13, 2025 · 3 comments
Assignees

Comments

@antonioalegria
Copy link

antonioalegria commented Apr 13, 2025

I'm constantly getting this message in stderr when displaying a pandas dataframe. This pollutes what the agent sees and may even impact our ability to getting the displayed dataframe data.

/usr/local/lib/python3.10/site-packages/jupyter_client/session.py:721: UserWarning: Message serialization failed with:
Out of range float values are not JSON compliant
Supporting this message is deprecated in jupyter-client 7, please make sure your message is JSON-compliant
  content = self.pack(content)

This is probably in your serialization code, perhaps? Can you check this and see if you or us can mitigate this warning?

This happens with a e2b sandbox template created today with the latest version of e2b.

Copy link

linear bot commented Apr 13, 2025

@mishushakov
Copy link
Member

Hey, thanks for reporting. Will take a closer look. Do you have an example code I can try where the issue is occurring?

@antonioalegria
Copy link
Author

Here you go.

import pandas as pd
import numpy as np

# Data for the DataFrame
# Using a dictionary where keys are column names and values are lists of column data
data = {
    'SpecialFloats': [
        0.0,             # Standard float zero
        np.nan,          # Not a Number (from NumPy)
        pd.NA,           # Pandas' dedicated missing value marker
        None,            # Python's None, often treated as NaN in float columns
        np.inf,          # Positive infinity (from NumPy)
        -np.inf          # Negative infinity (from NumPy)
    ]
}

# Create the Pandas DataFrame
df = pd.DataFrame(data)
display(df)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants