Closed kneelesh48 closed 1 year ago
It happens even when I set enable_cache=False
@kneelesh48 please check it out, should have been fixed with version 0.5.5
. Feel free to reopen if the problem persists!
Hey, that's great, everything works as expected, even in streamlit. Thank you so much for your work.
There is still a small bug while running in streamlit on macOS
I still get the cache error when I set enable_cache=True
when I enter the prompt the second time, the first time it works fine.
I don't get any error if I set enable_cache=False
Here's the entire streamlit code
import os
import pandas as pd
import streamlit as st
from pandasai import PandasAI
from pandasai.middlewares.streamlit import StreamlitMiddleware
from dotenv import load_dotenv
load_dotenv()
from pandasai.llm.openai import OpenAI
llm = OpenAI(api_token=os.environ["OPENAI_API_TOKEN"])
# pandas_ai = PandasAI(llm, verbose=True, enable_cache=True)
pandas_ai = PandasAI(llm, verbose=True, enable_cache=False, middlewares=[StreamlitMiddleware()])
uploaded_file = st.file_uploader("Upload a file", type=['csv', 'xlsx'])
if uploaded_file is not None:
df = pd.read_csv(uploaded_file)
else:
df = pd.DataFrame({
"country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
"gdp": [19294482071552, 2891615567872, 2411255037952, 3435817336832, 1745433788416, 1181205135360, 1607402389504, 1490967855104, 4380756541440, 14631844184064],
"happiness_index": [6.94, 7.16, 6.66, 7.07, 6.38, 6.4, 7.23, 7.22, 5.87, 5.12]
})
with st.expander("Show DataFrame"):
st.dataframe(df.head())
prompt = 'Which are the 5 happiest countries?'
# prompt = 'Plot a bar chart of gdp and happines index of each country'
# prompt = "Plot the histogram of countries showing for each the gdp, using different colors for each bar"
prompt = st.text_input("Enter prompt", value=prompt)
response = pandas_ai(df, prompt=prompt)
if response is not None:
st.write(response)
And here's the error
error: [Errno 35] Resource temporarily unavailable: '/Users/neeleshkumar/Library/CloudStorage/OneDrive-Personal/Code/Python/PandasAI/cache/cache'
Traceback
File "/opt/homebrew/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
exec(code, module.__dict__)
File "/Users/neeleshkumar/Library/CloudStorage/OneDrive-Personal/Code/Python/PandasAI/pandas_ai_streamlit.py", line 24, in <module>
pandas_ai = PandasAI(llm, verbose=True, enable_cache=True, middlewares=[StreamlitMiddleware()])
File "/opt/homebrew/lib/python3.10/site-packages/pandasai/__init__.py", line 192, in __init__
self._cache = Cache()
File "/opt/homebrew/lib/python3.10/site-packages/pandasai/helpers/cache.py", line 22, in __init__
self.cache = shelve.open(self.filepath)
File "/opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shelve.py", line 243, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shelve.py", line 227, in __init__
Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
File "/opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/dbm/__init__.py", line 95, in open
return mod.open(file, flag, mode)
Any updates on that? I am having the same error as @kneelesh48 .
@kneelesh48 @felipmorais I think this could be related to the permissions of the cache folder. Are you running it inside docker? One suggestion that I can give you is to create a /cache
folder yourself with the right permissions.
Let me know!
@gventuri I'm having the same issue running it in a docker container -- what do you mean create my own cache folder with the right permissions? The cache folder seems to be automatically generated.
This is my code:
pandas_ai = PandasAI(
llm,
enable_cache=False,
enforce_privacy=True,
conversational=True,
middlewares=[StreamlitMiddleware()],
)
Also having this problem in a docker container.
Same problem is happening in Docker container. Its working now after setting enable_cache=False But the plots are not getting displayed in the streamlit application via docker.
Same thing works when executed outside docker but not in docker
I keep getting this error (simply running as .py script). Tried to create the directory myself and changing directory and file permissions and the problem persists.
same problem
Yes same problem.. on ubuntu desktop _gdbm.error: [Errno 11] Resource temporarily unavailable: '/home/shudh/PycharmProjects/pythonProject/pandas-ai/cache/cache' .. gave permissions and retried but still the same issue .. removed cache manually and re ran ..but still same issue..
Ok I can confirm that it does not happen when I disable cache..but I don't want to disable cache as I am running low on OPENAI credits :) ...
🐛 Describe the bug
This returns the following error error: [Errno 35] Resource temporarily unavailable: '/opt/homebrew/lib/python3.10/site-packages/cache/cache'
Trackback:
Expected behaviour: This should not happen. I tested it on Windows and this error doesn't happen on Windows