-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plot chart failing on windows #1593
Comments
Hi @pulkitmehtawork please edit your original ticket so that:
Thanks! |
Done. |
What about using this code rather than the agent? Let me know what happens using directly the chat method on the panda-ai dataframe or, alternatively
For more details and understanding the 3.0, please read: https://docs.getpanda.ai/v3/chat-and-output |
Still the same error . |
We will investigate the issue. Thanks @pulkitmehtawork |
Hello dear, I have fixed the issue by changing the hard coded name of the image. since it is temp_chart, once changed to ..\temp_chart.png windows deal with it as \t. Solution: Go to source code and change the temp_chart.png to chart_temp.png. This should work! @gdcsinaptik a quick suggestion, including uuid and letting the name of the image be a dynamic every call is very beneficial. By this, you will keep all generated images stored properly rather than overriding them! To do so, I have removed the temp_chart.png and replace it with f"{uuid}.png". |
Env: Windows 10 Pro
Pandas AI version: 3.0.0b8
Python version : 3.11.9
`
import pandasai as pai
from pandasai_openai import AzureOpenAI
from pandasai import Agent
#removed key, end point
llm = AzureOpenAI(
api_token="",
azure_endpoint = "",
deployment_name="gpt-4o",
api_version="2024-02-15-preview") # The name of your deployed model
pai.config.set({"llm": llm})
df = pai.read_csv("data/heart.csv")
agent = Agent(df,config={
"llm": llm,
"verbose": True,
"save_charts": True,
"open_charts": False,
"save_charts_path": "/exports/charts/",
})
response = agent.chat("Plot age frequency.")
print(response)
`
When I load 1 csv in pandasai and query - plot the age frequency . It throws below error .
Seems to be path issue in windows. Please check .
Error stack trace :
plot_filename = plot_age_frequency()
result = {'type': 'plot', 'value': plot_filename}
2025-02-06 16:39:10 [INFO] Retrying execution (1/3)...
2025-02-06 16:39:10 [INFO] Execution failed with error: Traceback (most recent call last):
File "C:\Users\pulkitme\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pandasai\core\code_execution\code_executor.py", line 29, in execute
exec(code, self._environment)
File "", line 20, in
File "", line 15, in plot_age_frequency
File "C:\Users\pulkitme\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\pyplot.py", line 1023, in savefig
res = fig.savefig(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\pulkitme\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\figure.py", line 3378, in savefig
self.canvas.print_figure(fname, **kwargs)
File "C:\Users\pulkitme\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\backend_bases.py", line 2366, in print_figure
result = print_method(
^^^^^^^^^^^^^
File "C:\Users\pulkitme\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\backend_bases.py", line 2232, in
print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
^^^^^
File "C:\Users\pulkitme\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\backends\backend_agg.py", line 509, in print_png
self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File "C:\Users\pulkitme\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\backends\backend_agg.py", line 458, in _print_pil
mpl.image.imsave(
File "C:\Users\pulkitme\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\image.py", line 1689, in imsave
image.save(fname, **pil_kwargs)
File "C:\Users\pulkitme\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\PIL\Image.py", line 2563, in save
fp = builtins.open(filename, "w+b")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 22] Invalid argument: 'C:\pandasai\exports\charts\temp_chart.png'
The text was updated successfully, but these errors were encountered: