You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OS version: Debian GNU/Linux 12 (bookworm)
Python version: Python 3.11.2
The current version of pandasai being used: 2.4.0
🐛 Describe the bug
When instantiating a new Agent, the following error occurs, indicating that seaborn should not be an optional dependency:
Traceback (most recent call last):
File ".../streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
result = func()
^^^^^^
File ".../streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec
exec(code, module.__dict__)
File ".../app.py", line 1, in <module>
from pandasai import Agent
File ".../pandasai/__init__.py", line 6, in <module>
from pandasai.smart_dataframe import SmartDataframe
File ".../pandasai/smart_dataframe/__init__.py", line 27, in <module>
from pandasai.agent import Agent
File ".../pandasai/agent/__init__.py", line 1, in <module>
from .agent import Agent
File ".../pandasai/agent/agent.py", line 5, in <module>
from pandasai.agent.base import BaseAgent
File ".../pandasai/agent/base.py", line 8, in <module>
from pandasai.agent.base_security import BaseSecurity
File ".../pandasai/agent/base_security.py", line 2, in <module>
from pandasai.pipelines.pipeline import Pipeline
File ".../pandasai/pipelines/__init__.py", line 3, in <module>
from .pipeline import Pipeline
File ".../pandasai/pipelines/pipeline.py", line 5, in <module>
from pandasai.config import load_config_from_json
File ".../pandasai/config.py", line 4, in <module>
from . import llm
File ".../pandasai/llm/__init__.py", line 5, in <module>
from .google_gemini import GoogleGemini
File ".../pandasai/llm/google_gemini.py", line 16, in <module>
from ..helpers.optional import import_dependency
File ".../pandasai/helpers/optional.py", line 22, in <module>
from pandasai.safe_libs.restricted_seaborn import RestrictedSeaborn
File ".../pandasai/safe_libs/restricted_seaborn.py", line 1, in <module>
import seaborn as sns
ModuleNotFoundError: No module named 'seaborn'
After installing seaborn using poetry add seaborn, the following error occurs, indicating that pyyaml is also required:
Traceback (most recent call last):
File ".../streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
result = func()
^^^^^^
File ".../streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec
exec(code, module.__dict__)
File ".../app.py", line 1, in <module>
from pandasai import Agent
File ".../pandasai/__init__.py", line 6, in <module>
from pandasai.smart_dataframe import SmartDataframe
File ".../pandasai/smart_dataframe/__init__.py", line 27, in <module>
from pandasai.agent import Agent
File ".../pandasai/agent/__init__.py", line 1, in <module>
from .agent import Agent
File ".../pandasai/agent/agent.py", line 5, in <module>
from pandasai.agent.base import BaseAgent
File ".../pandasai/agent/base.py", line 8, in <module>
from pandasai.agent.base_security import BaseSecurity
File ".../pandasai/agent/base_security.py", line 2, in <module>
from pandasai.pipelines.pipeline import Pipeline
File ".../pandasai/pipelines/__init__.py", line 3, in <module>
from .pipeline import Pipeline
File ".../pandasai/pipelines/pipeline.py", line 5, in <module>
from pandasai.config import load_config_from_json
File ".../pandasai/config.py", line 6, in <module>
from .schemas.df_config import Config
File ".../pandasai/schemas/df_config.py", line 4, in <module>
from pandasai.helpers.dataframe_serializer import DataframeSerializerType
File ".../pandasai/helpers/dataframe_serializer.py", line 4, in <module>
import yaml
ModuleNotFoundError: No module named 'yaml'
To resolve this, I had to run poetry add pyyaml, and then everything worked correctly.
Suggestion
Make seaborn a required dependency: It appears that seaborn is being imported without being marked as a required dependency, causing errors when it's missing. It should either be made a required dependency or a check should be added to verify if it is present in the environment before importing.
Make pyyaml a required dependency: Similarly, pyyaml should be listed as a required dependency, as it is necessary for proper functionality.
The text was updated successfully, but these errors were encountered:
Hey @desertproject! I'm here to help you with any bugs, questions, or contributions you have. I'm a bot designed to assist you while you wait for a human maintainer.
The issue you're encountering is due to seaborn and pyyaml being used in the code without being listed as required dependencies in the pyproject.toml file. Currently, seaborn is treated as an optional dependency, and the codebase includes mechanisms to handle its absence using conditional imports [1]. However, it seems that in some parts of the code, seaborn is imported directly, leading to the ModuleNotFoundError when it's not installed.
To address this, you can consider the following suggestions:
Make seaborn a required dependency: If seaborn is essential for the functionality of the project, it should be added to the required dependencies in the pyproject.toml file. This ensures that it is installed automatically when setting up the project.
Make pyyaml a required dependency: Similarly, if pyyaml is necessary for the project to function correctly, it should also be added to the required dependencies.
These changes would prevent the ModuleNotFoundError by ensuring that both seaborn and pyyaml are installed when the project is set up. If you have the ability to modify the pyproject.toml file, you can add these dependencies there. Otherwise, you might want to discuss this with the maintainers to see if they can update the dependency list accordingly.
System Info
OS version:
Debian GNU/Linux 12 (bookworm)
Python version:
Python 3.11.2
The current version of pandasai being used:
2.4.0
🐛 Describe the bug
When instantiating a new Agent, the following error occurs, indicating that seaborn should not be an optional dependency:
After installing seaborn using
poetry add seaborn
, the following error occurs, indicating that pyyaml is also required:To resolve this, I had to run
poetry add pyyaml
, and then everything worked correctly.Suggestion
Make seaborn a required dependency: It appears that seaborn is being imported without being marked as a required dependency, causing errors when it's missing. It should either be made a required dependency or a check should be added to verify if it is present in the environment before importing.
Make pyyaml a required dependency: Similarly, pyyaml should be listed as a required dependency, as it is necessary for proper functionality.
The text was updated successfully, but these errors were encountered: