vtraag / leidenalg

Implementation of the Leiden algorithm for various quality functions to be used with igraph in Python.
GNU General Public License v3.0
606 stars 78 forks source link

AttributeError: module 'igraph' has no attribute 'VertexClustering' with latest igraph #144

Closed Zethson closed 1 year ago

Zethson commented 1 year ago

import leidenalg results in

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zeth/miniconda3/envs/pertpy/lib/python3.10/site-packages/leidenalg/__init__.py", line 35, in <module>
    from .functions import ALL_COMMS
  File "/home/zeth/miniconda3/envs/pertpy/lib/python3.10/site-packages/leidenalg/functions.py", line 18, in <module>
    from .VertexPartition import *
  File "/home/zeth/miniconda3/envs/pertpy/lib/python3.10/site-packages/leidenalg/VertexPartition.py", line 5, in <module>
    class MutableVertexPartition(_ig.VertexClustering):
AttributeError: module 'igraph' has no attribute 'VertexClustering'

Versions:

python = 3.10.6
igraph = "^0.10.6"
python-igraph = "^0.10.6"
leidenalg = "^0.10.0"
Zethson commented 1 year ago

I played around with igraph and the issue does not appear with igraph version 0.10.4 or smaller. They made two patch releases (0.10.5 - not tested; and 0.10.6 which does not work)

vtraag commented 1 year ago

Sorry, I can't reproduce this, starting fro a clean conda environment:

conda create -n test leidenalg -c conda-forge

which in this case installs leidenalg=0.10.0 and python-igraph=0.10.6. Could you please show how you installed all packages?

Zethson commented 1 year ago

Huh, now I can't reproduce it either. IDK what happened earlier :/

I'll get back to you when I'll run into it again

vtraag commented 1 year ago

OK, no problem!

As a further note, I also can't reproduce this in a clean venv installing leidenalg and igraph using pip.

szhorvat commented 1 year ago

@Zethson

python = 3.10.6 igraph = "^0.10.6" python-igraph = "^0.10.6" leidenalg = "^0.10.0"

Just a heads up: python-igraph is just a redirect to igraph, and it will soon cease to be updated. Please only pip install the igraph package, not python-igraph.

vtraag commented 1 year ago

Just a heads up: python-igraph is just a redirect to igraph, and it will soon cease to be updated. Please only pip install the igraph package, not python-igraph.

Yes, this holds for pip indeed. However, note that the OP is using conda. In conda, igraph refers to the C core, while python-igraph refers to the Python interface. See https://github.com/conda-forge/python-igraph-feedstock/issues/42 for a discussion about this in the context of the python-igraphigraph transition on PyPI. Note that they also host r-igraph, so from that point of view the naming makes sense.