'AttributeError: module 'matplotlib.cbook' has no attribute 'iterable'

When I run this code:

import networkx as nx

G = nx.complete_graph(5)

nx.draw_networkx(G)

I got this error: AttributeError: module 'matplotlib.cbook' has no attribute 'iterable'

How can I get rid of that error? And thank you.

P.S. I run that code in the cloud, not on my laptop.



Solution 1:[1]

Downgrade matplotlib version to 2.2.3

https://github.com/palash1992/GEM/issues/51

Solution 2:[2]

Just ran into this issue and found that upgrading networkx works perfectly

pip install --upgrade networkx

Solution 3:[3]

upgrade your networkx version can also do

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alex
Solution 2 EoinS
Solution 3 feverer