Attributeerror: module scipy.sparse has no attribute coo_array

Attributeerror_ module scipy.sparse has no attribute coo_array

attributeerror: module scipy.sparse has no attribute coo_array error occurs if you are running lower version of scipy ( less than v1.8 )   with scipy.sparse.*_array or similar functions. Since this scipy.sparse.*_array or similar functions are part of scipy release 1.8 . Hence if you have lower version of scipy , if will create code incompatibility and throw the same AttributeError.  Sometimes developers do not explicitly invoke scipy.sparse but any other package like networkx etc implicitly invokes it and we get this error.

Attributeerror: module scipy.sparse has no attribute coo_array ( Solutions ) –

To remove this incompatibility we can either upgrade scipy to a version greater than 1.8 or we can downgrade the underline package which is implicitly invoking the scipy. But I will recommend going for option one upgrade. Because lowering any package version may create multiple similar incompatibility errors.  Anyways let’s start the solutioning.

Solution 1: Upgrading scipy version > 1.8 –

1. Generally pip is the first choice for everyone for package management in Python. Here is the command –

pip install scipy==1.8.0

or the current version is 1.10.0 hence –

pip install scipy

2. If you are using the conda then you can try the below one as well.

conda install 'scipy>=1.8'

3. If you want to use the source code then you can download any branch from the git which is greater than 1.8 release and run the below command-

Attributeerror module scipy.sparse has no attribute coo_array git fix
Attributeerror module scipy.sparse has no attribute coo_array git fix
python install setup.py

Solution 2: Downgrading Super package (like networkx) –

Here super packages are those python module which implicitly invoke scipy.sparse. If we downgrade them, It will resolve this error. Just to make it more specific for better understanding if we downgrade the networkx module lower to the 2.7 version ( Version release details networkx)  . we will fix the problem. Here is the command for this.

pip install networkx==2.6.3

Other Similar Errors :

Module ‘scipy’ has no attribute ‘integrate’ ( Solved )

Module ‘scipy’ has no attribute ‘stats’ ( Solved )

Thanks
Data Science Learner Team

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Meet Abhishek ( Chief Editor) , a data scientist with major expertise in NLP and Text Analytics. He has worked on various projects involving text data and have been able to achieve great results. He is currently manages Datasciencelearner.com, where he and his team share knowledge and help others learn more about data science.
 
Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner