Errors after deploying the app

Hi
I created my first app using streamlit. It works without any errors in my own pc (Python 3.9.7) but when I deploy it on streamlit cloud (Python 3.9) I get this error:

AttributeError: 'DataFrameGroupBy' object has no attribute 'value_counts'

The line which this error refers to is:

df_grouped = df.groupby(by=[groupby_column], as_index=False).value_counts()
1 Like

I even tried running the app on ngrok and again get this error. I changed the pandas version to 1.0.5 in requirements.txt and rebooted the app but still it doesn’t work.
I really can’t understand why it doesn’t work on cloud while it perfectly runs on windows!

Hi @Kasra, welcome to the Streamlit community!

Can you post a link to the repo that you are deploying from?

Best,
Randy

1 Like

Thank you dear Randy.
https://github.com/Jafarik1998/kia

Hi @Kasra :wave:

You’ll notice in the pandas docs that version 1.0.5 of pandas does not contain a DataFrameGroupBy.value_counts method. It was added in later versions. For example, version 1.4.1 does contain a DataFrameGroupBy.value_counts method.

Pinning a pandas version in requirements.txt that supports the method should fix the issue.

pandas==1.4.1

Best, :balloon:
Snehan

2 Likes

Thank you dear Snehan.
I did it and the result was these errors:

ERROR: Could not find a version that satisfies the requirement pandas==1.4.1 (from versions: 0.1, 0.2, 0.3.0, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.16.2, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 0.19.2, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.21.0, 0.21.1, 0.22.0, 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.23.4, 0.24.0, 0.24.1, 0.24.2, 0.25.0, 0.25.1, 0.25.2, 0.25.3, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5)

ERROR: No matching distribution found for pandas==1.4.1

Please ensure you have selected Python 3.8 or Python 3.9 while deploying your app on Streamlit Cloud. Pandas version 1.4.1 isn’t available for Python 3.7.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.