question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

module 'louvain._c_louvain' has no attribute '_set_rng_seed'

See original GitHub issue

trying to run louvain clustering but got the error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-22-fe1390cdc24a> in <module>
----> 1 sc.tl.louvain(adata, resolution=1.0)

~/miniconda3/envs/scrna/lib/python3.7/site-packages/scanpy/tools/_louvain.py in louvain(adata, resolution, random_state, restrict_to, key_added, adjacency, flavor, directed, use_weights, partition_type, partition_kwargs, copy)
    136                 partition_kwargs["weights"] = weights
    137             logg.info('    using the "louvain" package of Traag (2017)')
--> 138             louvain.set_rng_seed(random_state)
    139             part = louvain.find_partition(
    140                 g, partition_type,

~/miniconda3/envs/scrna/lib/python3.7/site-packages/louvain/functions.py in set_rng_seed(seed)
     23 def set_rng_seed(seed):
     24   """ Set seed for internal random number generator. """
---> 25   _c_louvain._set_rng_seed(seed)
     26 
     27 def find_partition(graph, partition_type, initial_membership=None, weights=None, **kwargs):

AttributeError: module 'louvain._c_louvain' has no attribute '_set_rng_seed'
sc.tl.louvain(adata, resolution=1.0)

Python 3.7

Versions:

scanpy==1.4.6 anndata==0.7.1 umap==0.4.2 numpy==1.18.3 scipy==1.4.1 pandas==1.0.3 scikit-learn==0.22.2.post1 statsmodels==0.11.1 python-igraph==0.8.2 louvain==0.6.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
davemcgcommented, May 18, 2020

If anyone is stuck waiting for the new release, you can edit your .../lib/python3.7/site-packages/scanpy/tools/_louvain.py with these changes:

Add: partition_kwargs["seed"] = random_state Remove: louvain.set_rng_seed(random_state)

From: https://github.com/theislab/scanpy/pull/1197/commits/b54d67b9d6b41269c1612df0242210d1279ede85

0reactions
vanhoan310commented, Jul 16, 2020

Install old louvain package will solve the problem: pip install louvain==0.6.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

module 'louvain._c_louvain' has no attribute '_set_rng_seed'
trying to run louvain clustering but got the error: ... module 'louvain._c_louvain' has no attribute '_set_rng_seed' #1191.
Read more >
Python AttributeError: module has no attribute - Stack Overflow
AttributeError: module 'sample' has no attribute 'Sampler'. The formal parameter is named sample , yet you imported sample .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found