e2b-dev / code-interpreter

Python & JS/TS SDK for running AI-generated code/code interpreting in your AI app
https://e2b.dev
Apache License 2.0
1.24k stars 88 forks source link

ImportError: cannot import name 'DataAnalysis' from 'e2b' #29

Closed Timmy485 closed 3 months ago

Timmy485 commented 3 months ago

rying to follow this guide: https://e2b.dev/blog/build-ai-data-analyst-with-langchain-and-e2b , however i run into this error

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File c:\Users\TurnerZ\Documents\GitHub\RAIA\.e2b\Lib\site-packages\langchain_community\tools\e2b_data_analysis\tool.py:117, in E2BDataAnalysisTool.__init__(self, api_key, cwd, env_vars, on_stdout, on_stderr, on_artifact, on_exit, **kwargs)
    116 try:
--> 117     from e2b import DataAnalysis
    118 except ImportError as e:

ImportError: cannot import name 'DataAnalysis' from 'e2b' (c:\Users\TurnerZ\Documents\GitHub\RAIA\.e2b\Lib\site-packages\e2b\__init__.py)

The above exception was the direct cause of the following exception:

ImportError                               Traceback (most recent call last)
Cell In[7], line 13
      9     with open(f"./charts/{basename}", "wb") as f:
     10         f.write(file)
---> 13 e2b_data_analysis_tool = E2BDataAnalysisTool(
     14     # Pass environment variables to the sandbox
     15     env_vars={"MY_SECRET": "secret_value"},
     16     on_stdout=lambda stdout: print("stdout:", stdout),
     17     on_stderr=lambda stderr: print("stderr:", stderr),
     18     on_artifact=save_artifact,
     19 )

File c:\Users\TurnerZ\Documents\GitHub\RAIA\.e2b\Lib\site-packages\langchain_community\tools\e2b_data_analysis\tool.py:119, in E2BDataAnalysisTool.__init__(self, api_key, cwd, env_vars, on_stdout, on_stderr, on_artifact, on_exit, **kwargs)
    117     from e2b import DataAnalysis
...
    123 # If no API key is provided, E2B will try to read it from the environment
    124 # variable E2B_API_KEY
    125 super().__init__(description=base_description, **kwargs)

ImportError: Unable to import e2b, please install with `pip install e2b`.

when trying to initialize E2BDataAnalysisTool as stated in the guide e2b version 0.17.1

jakubno commented 3 months ago

Hi @Timmy485, DataAnalysis class was deprecated. This package should be better version of the original DataAnalysis class. If you want to follow the tutorial you can install old version. Last version with DataAnalysis class is 0.14.14. You can install it with

pip install e2b==0.14.14

Let me know if this helps

Timmy485 commented 3 months ago

that seemed to fix it, is there any updated example I can follow though rather than the current I'm using?

jakubno commented 3 months ago

Not right now. Actually we're just finishing new version of SDK, which will improve speed, DX and more. Once we release it, we will return to the examples and update them to new SDK version.

Timmy485 commented 3 months ago

noted, I would love to get pinged when that's out :)

mlejva commented 3 months ago

He @Timmy485 just wanted to add one more thing. We have an official cookbook full of examples, including LangChain - https://github.com/e2b-dev/e2b-cookbook