taynaud / python-louvain

Louvain Community Detection
BSD 3-Clause "New" or "Revised" License
964 stars 200 forks source link

AttributeError: 'Graph' object has no attribute 'edges_iter' #18

Closed aminKMT closed 6 years ago

aminKMT commented 6 years ago

Hi! I'm using mapmatcher python code, but when I run it with both my data and test data it gives me the attribute error (AttributeError: 'Graph' object has no attribute 'edges_iter'). I updated my networkx by pip install, but it still did not work and I got the same error. could you please let me know how I can solve it. Thanks, In the following you can see what I got in python:

track size:14 Number of segments: 745 C:\Users\amin.keramati\Desktop\tPRROMTO2\AminShp\testSegments.shp graph size (excluding unconnected parts): 573

Traceback (most recent call last): File "C:\Users\amin.keramati\Desktop\tPRROMTO2\mapmatcher\mapmatcher11.py", line 510, in opt = mapMatch(trackname, roadname, 20, 10, 50) File "C:\Users\amin.keramati\Desktop\tPRROMTO2\mapmatcher\mapmatcher11.py", line 87, in mapMatch graph = getNetworkGraph(segments,lengths) File "C:\Users\amin.keramati\Desktop\tPRROMTO2\mapmatcher\mapmatcher11.py", line 469, in getNetworkGraph for n0, n1 in sg.edges_iter(): AttributeError: 'Graph' object has no attribute 'edges_iter'

taynaud commented 6 years ago

Hello,

It looks like a version mismatch. Networkx 2.0 removed the edges_iter function. You may downgrade python louvain to a version < 0.9, for instance pip install 'python-louvain<0.9' and continue to use a networkx < 2.0. The traceback you give seems related to mamaptcher11.py using a networkx<2.0 code.

Best

alexlenail commented 6 years ago

@taynaud what is the most up to date version of python-louvain? When I just do a pip install python-louvain I get this error as well, coming from incompatibility with networkx 2.0. Are there plans to support the new networkx?

taynaud commented 6 years ago

new networkx is supported since 0.9. There was an issue in requirements which is fixed now.

Best

Skoyer commented 5 years ago

Hello,

It looks like a version mismatch. Networkx 2.0 removed the edges_iter function. You may downgrade python louvain to a version < 0.9, for instance pip install 'python-louvain<0.9' and continue to use a networkx < 2.0. The traceback you give seems related to mamaptcher11.py using a networkx<2.0 code.

Best

I just upgraded both Networkx and python-louvain:

pip install python-louvain --upgrade
pip install networkx --upgrade

And now everything works.

sabershakeri commented 4 years ago

just downgrade both of them to :

pip install python-louvain==0.8 pip install networkx ==1.10

Hello, It looks like a version mismatch. Networkx 2.0 removed the edges_iter function. You may downgrade python louvain to a version < 0.9, for instance pip install 'python-louvain<0.9' and continue to use a networkx < 2.0. The traceback you give seems related to mamaptcher11.py using a networkx<2.0 code. Best

I just upgraded both Networkx and python-louvain:

pip install python-louvain --upgrade
pip install networkx --upgrade

And now everything works.