AttributeError: module 'numpy' has no attribute 'bool'

Hello,
When I run my app https://datavision.streamlit.app/ on the cloud, a get

AttributeError: module ‘numpy’ has no attribute ‘bool’. np.bool was a deprecated alias for the builtin bool. To avoid this error in existing code, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.bool_ here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: NumPy 1.20.0 Release Notes — NumPy v2.0.dev0 Manual

But the app works well in my local computer.
I tried to downgrade numpy version(from 1.24 to 1.19) like I saw in forums but the error persists.

Github: data-vision

Could you help me please?

Thank you

Hi there @Dav ,

Do you still need support with this? If so, please update the link to your repo so I can have a look :slight_smile:

To avoid this error in existing code, use bool by itself.

Hi @marduk .
Sorry the project was private, it’s public now I you want have a look
Thank you !

Hi Goyo,
I don’t know how
The error message says the culprit is here:

File "/mount/src/data-vision/app.py", line 466, in <module>
    fig_na = visualizeNaValues(df)File "/mount/src/data-vision/app.py", line 170, in visualizeNaValues
    fig = px.imshow(df.isnull(), aspect='auto')

But It doesn’t indicate me what to do. (Sorry I’m a beginner)

Thank you

Hi again @Dav !

After looking at the error message again, the issue seems to be incompatibility between Plotly and NumPy libraries. Try updating the plotly version in your requirements.txt file to a more recent one. (Maybe the app works correctly in your local directory because there you already have a more recently version.) Hope this helps!

There must be something more in the traceback, since that code does not reference np.bool. You might need to upgrade plotly or pandas.

Hi,
I updated all of them, streamlit, pandas, numpy, plotly.
Got the requirement from my local (from which its working well)
But still, on the cloud, it doesn’t work.
When I remove px.imshow (in the visualizeNaValues()) it’s working though, but I don’t know why, and if I could replace px.imshow by something else who does the job well

Again, Thank you!

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