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
I looked up similar problems in the past and found that the drawing problems of GPT-3.5 and BambooLLM have been solved, but I still have the same problem when I run the code.
importosimportpandasaspdfrompandasaiimportAgent# Sample DataFramesales_by_country=pd.DataFrame({
"country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
"revenue": [5000, 3200, 2900, 4100, 2300, 2100, 2500, 2600, 4500, 7000]
})
os.environ["PANDASAI_API_KEY"] ="MY_API_KEY"agent=Agent(sales_by_country,config={
"save_charts": True,
"open_charts": True,
"save_charts_path": "/exports/charts",
})
response=agent.chat('Which are the top 5 countries by sales?')
r2=agent.chat(
"Plot the histogram of countries showing for each one the gd. Use different colors for each bar",
)
Traceback (most recent call last):
File "/root/miniconda3/envs/DataAI/lib/python3.9/site-packages/pandasai/pipelines/chat/generate_chat_pipeline.py", line 333, in run
output = (
File "/root/miniconda3/envs/DataAI/lib/python3.9/site-packages/pandasai/pipelines/pipeline.py", line 137, in run
raise e
File "/root/miniconda3/envs/DataAI/lib/python3.9/site-packages/pandasai/pipelines/pipeline.py", line 101, in run
step_output = logic.execute(
File "/root/miniconda3/envs/DataAI/lib/python3.9/site-packages/pandasai/pipelines/chat/code_execution.py", line 133, in execute
{"content_type": "response", "value": ResponseSerializer.serialize(result)},
File "/root/miniconda3/envs/DataAI/lib/python3.9/site-packages/pandasai/responses/response_serializer.py", line 35, in serialize
with open(result["value"], "rb") as image_file:
FileNotFoundError: [Errno 2] No such file or directory: '/exports/charts/8998e704-c205-46ed-9a6c-3c23a031f93c.png'
The text was updated successfully, but these errors were encountered:
Hey @Catherineasdzz! I'm here to help you with any bugs, questions, or contributions. Let's tackle this together!
To resolve the FileNotFoundError when trying to save charts using the pandasai library, ensure that the directory where you intend to save the chart exists before attempting to save the file. You can modify your code to create the directory if it doesn't exist using the following approach:
importosimportpandasaspdfrompandasaiimportAgentfrompathlibimportPath# Sample DataFramesales_by_country=pd.DataFrame({
"country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
"revenue": [5000, 3200, 2900, 4100, 2300, 2100, 2500, 2600, 4500, 7000]
})
os.environ["PANDASAI_API_KEY"] ="MY_API_KEY"# Define the path where charts will be savedsave_charts_path=Path("/exports/charts")
# Ensure the directory existssave_charts_path.mkdir(parents=True, exist_ok=True)
agent=Agent(sales_by_country, config={
"save_charts": True,
"open_charts": True,
"save_charts_path": str(save_charts_path),
})
response=agent.chat('Which are the top 5 countries by sales?')
r2=agent.chat(
"Plot the histogram of countries showing for each one the gd. Use different colors for each bar",
)
This code snippet ensures that the directory /exports/charts is created if it does not already exist, preventing the FileNotFoundError[1].
I''m sure that the directory /exports/charts has already existed, but the problem still exists. I even used GPT-4o but the problem is still not solved. @dosu
System Info
pandasai 2.3.0
ubuntu 0.20.04.1
python 3.9
🐛 Describe the bug
I looked up similar problems in the past and found that the drawing problems of GPT-3.5 and BambooLLM have been solved, but I still have the same problem when I run the code.
The text was updated successfully, but these errors were encountered: