I've been working with the fastStructure program and am on the step of analyzing model complexity using the provided chooseK.py script. I have been running into the following error:

Traceback (most recent call last):
  File "chooseK.py", line 109, in <module>
    bestKs = parse_varQs(files)
  File "chooseK.py", line 54, in parse_varQs
    Q = Q/utils.insum(Q,[1])
AttributeError: module 'vars' has no attribute 'insum'

I have run into 'AttributeError' messages in the past and have attempted the solution of renaming files in my working directory that may be shadowing the real module (similar to: https://stackoverflow.com/questions/36530726/using-numpy-module-object-has-no-attribute-array), but this hasn't fixed anything. Reinstalling Numpy/Scipy/fastStructure has also been a dead end.

Any suggestions are much appreciated! Happy to provide more info as needed.


  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Commented Jul 7, 2022 at 21:12
  • $\begingroup$ did you build the library extensions? The module vars.utils are imported as utils, so the attribute insum is undetected. stackoverflow.com/questions/46312470/… $\endgroup$
    – zorbax
    Commented Jul 8, 2022 at 0:13

1 Answer 1


Could you try loading fastStructure via conda?

conda create --name faststruc python=3.9 # there can be issues with 3.10
conda activate faststruc
conda install -c bioconda faststructure 

It will then ask you whether you want to install numpy and scipy automatically. Furthermore all dependencies are installed and connectivity will have already been tested. You can easily delete everything afterwards by deleting the environment faststruc so keeps everything clean.

The code in question is here:


Its a numpy calculation, what they are doing is navigating Python by leveraging the power of numpy, which is very fast.

Code ...

bestKs = []
for file in files:
    handle = open(file,'r')
    Q = np.array([map(float,line.strip().split()) for line in handle])
    Q = Q/utils.insum(Q,[1])
    N = Q.shape[0]
    C = np.cuemsum(np.sort(Q.sum(0))[::-1])

return bestKs

The code looks good, they know their stuff.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.