Open anilmadishetty2498 opened 2 months ago
Hello, @anilmadishetty2498! 👋 I'm here to help you with any bugs, questions, or contribution guidance while you wait for a human maintainer.
To resolve the ImportError: cannot import name 'OpenAI' from 'openai'
when running the code from pandasai.llm.local_llm import LocalLLM
, you need to ensure that you are importing the OpenAI
class from the correct module within the pandasai
package. The correct import statement should be:
from pandasai.llm.openai import OpenAI
Make sure that your code reflects this import statement. If you are trying to use LocalLLM
, ensure that it is correctly defined and imported from the appropriate module within the pandasai
package. Here is an example of how LocalLLM
is defined:
from pandasai.llm.local_llm import LocalLLM
Ensure that you have the openai
package installed and properly configured in your environment. If the issue persists, double-check the version compatibility between the openai
package and the pandasai
package. The pandasai
documentation specifies that the openai
package version should be less than 2 [1].
Additionally, you might find it helpful to refer to similar issues:
To continue talking to Dosu, mention @dosu.
thank you for your quick workaround, let me check
thank you it worked
System Info
Python 3.11.7
🐛 Describe the bug
----> 1 from pandasai.llm.local_llm import LocalLLM
File c:\Users\AKM098\AppData\Local\anaconda3\Lib\site-packages\pandasai\llm\local_llm.py:5 1 from future import annotations 3 from typing import TYPE_CHECKING ----> 5 from openai import OpenAI 7 from ..helpers.memory import Memory 8 from ..prompts.base import BasePrompt
ImportError: cannot import name 'OpenAI' from 'openai' (c:\Users\USERID\AppData\Local\anaconda3\Lib\site-packages\openai__init__.py)