Exception ignored in: <async_generator object Connect.__aiter__ at 0x766b75501b40>
Traceback (most recent call last):
File "/home//Project/Project/LlmKira/Openaibot/.venv/lib/python3.11/site-packages/e2b/sandbox/websocket_client.py", line 107, in _connect
Exception ignored in: <async_generator object Connect.__aiter__ at 0x766b75500940>
Traceback (most recent call last):
File "/home//Project/Project/LlmKira/Openaibot/.venv/lib/python3.11/site-packages/e2b/sandbox/websocket_client.py", line 107, in _connect
break
RuntimeError: async generator ignored GeneratorExit
break
RuntimeError: async generator ignored GeneratorExit
import base64
import io
import nest_asyncio
from e2b_code_interpreter import CodeInterpreter
nest_asyncio.apply()
code = """
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 20, 100)
y = np.sin(x)
plt.plot(x, y)
plt.show()
"""
with CodeInterpreter() as sandbox:
# you can install dependencies in "jupyter notebook style"
sandbox.notebook.exec_cell("!pip install matplotlib")
# plot random graph
execution = sandbox.notebook.exec_cell(code)
# there's your image
image = execution.results[0].png
# example how to show the image / prove it works
i = base64.b64decode(image)
i = io.BytesIO(i)
with open("image.png", "wb") as f:
f.write(i.read())