Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'scipy.sparse' has no attribute 'coo_array'

Getting this error in my Jupyter Notebook What would be the best way to fix this utilizing conda instead of pip

I've attempted conda upgrade --all and that didnt seem to work

like image 969
Eliana Lopez Avatar asked Oct 14 '25 04:10

Eliana Lopez


2 Answers

The scipy.sparse.*_array functions were introduced with v1.8. The networkx package started requiring scipy >=1.8 with v2.7. So, either upgrade SciPy

conda install 'scipy>=1.8'

or downgrade NetworkX:

conda install 'networkx<2.7'

Part of the issue here is that, at the recommendation of a networkx developer, Conda Forge stopped explicitly requiring scipy as a dependency of networkx, and therefore there is no longer any constraint. I opened an issue on the feedstock to revisit coinstallation constraints (run_constrained specifications).

like image 104
merv Avatar answered Oct 17 '25 23:10

merv


As mentioned in this Github comment, I was trying to calculate the page rank (networkx.pagerank) of a graph on Google Colab when I encountered the same error. After executing the following code, the issue was resolved for me:

!pip install --upgrade scipy networkx

A Side Note: pip install refers to installing packages and leave the package as-is if it is already installed. But the --upgrade flag instructs pip to uninstall anything which is being upgraded/replaced. For more info on this, refer this official doc.

like image 34
Anindya Dey Avatar answered Oct 17 '25 23:10

Anindya Dey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!