{"id":23995,"library":"louvain","title":"louvain","description":"louvain is a Python implementation of the Louvain algorithm for community detection in large networks, based on the igraph library. Current version is 0.8.2, with a relatively stable release cadence (last update 2024).","status":"active","version":"0.8.2","language":"python","source_language":"en","source_url":"https://github.com/vtraag/louvain","tags":["community-detection","louvain","igraph","network-analysis"],"install":[{"cmd":"pip install louvain","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"louvain depends on igraph for graph representation and core algorithms","package":"python-igraph","optional":false}],"imports":[{"note":"","wrong":"","symbol":"louvain","correct":"import louvain"}],"quickstart":{"code":"import igraph as ig\nimport louvain\n\nG = ig.Graph.Erdos_Renyi(n=100, p=0.1, directed=False)\npartition = louvain.find_partition(G, louvain.ModularityVertexPartition)\nprint(partition.membership)","lang":"python","description":"Basic community detection using the Louvain algorithm on a random graph."},"warnings":[{"fix":"Use pip install leidenalg and import leidenalg (also by same author, more efficient)","message":"The standalone 'louvain' package is deprecated; consider using 'leidenalg' for newer algorithms","severity":"deprecated","affected_versions":">=0.8.0"},{"fix":"Run: pip install python-igraph","message":"Must install python-igraph separately","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure igraph is installed and imported before louvain","message":"The 'louvain' module does not install igraph automatically; missing igraph causes ImportError","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"pip install python-igraph","cause":"louvain requires igraph but doesn't install it as a dependency","error":"ModuleNotFoundError: No module named 'igraph'"},{"fix":"Use: partition = louvain.find_partition(G, louvain.ModularityVertexPartition)","cause":"Old API (v0.5.x) used 'best_partition'; newer versions use 'find_partition'","error":"ImportError: cannot import name 'find_partition' from 'louvain'"},{"fix":"Use louvain.find_partition() with appropriate partition class","cause":"The 'best_partition' function was removed after v0.5.x","error":"AttributeError: module 'louvain' has no attribute 'best_partition'","affected_versions":">=0.7"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}