ImportError: cannot import name 'transpose' from partially initialized module 'transposer' (most likely due to a circular import)
1
0
Entering edit mode
8 weeks ago
Razi • 0

Hi,

I try to run a script which starts like this:

import os, sys, subprocess, argparse, random, transposer, numpy, csv, scipy, gzip


I installed "transposer" on my local/mac by:

python3 -m pip install transposer


BUT, I got this error:

Traceback (most recent call last): import os, sys, subprocess, argparse, random, transposer, numpy, csv, scipy, gzip File "/opt/homebrew/lib/python3.10/site-packages/transposer/init.py", line 1, in from transposer import transpose
ImportError: cannot import name 'transpose' from partially initialized module 'transposer' (most likely due to a circular import) (/opt/homebrew/lib/python3.10/site-packages/transposer/init.py)


python conda transposer • 651 views
4
Entering edit mode
8 weeks ago

This module contains a single function transpose. I got the same error at first. As a quick fix with minimal change to other code, you can cd to /opt/homebrew/lib/python3.10/site-packages/transposer/ and delete __init.py__ or init.py and eventually __pycache* if it exists there.

Then do the following test in python CLI:

>>> from transposer import transpose
>>> transpose
<function transpose at 0x7fd807a35d30>

0
Entering edit mode

Thanks! It works now!

0
Entering edit mode

Regarding the transposer error, I could run it, BUT again it had this error:

....line 184, in <module> jj=transposer.transpose(i=args.v+ '/vcf_to_str/'+args.o+"TransposedStruct.str",d="\t",) AttributeError: module 'transposer' has no attribute 'transpose'


0
Entering edit mode

Sorry, I can't because I don't have or know the script or any reproducible data to make that case. I think the problem is in general that this seems to be a buggy setup, can you be sure that the results produced by the pipeline are valid? If it is just some standard VCF operation, you can possibly replace it with something more stable? Are you sure this script ever ran successfully before even or that it is a python3 script? And did you delete __pycache files?

0
Entering edit mode

Thanks! the problem is solved: I was using transposer.py by default (it doesn't have an atrribute transpase), so we should rename transposer.py

or I did this: mv transposer.py ../

in this case, it can't import from this script.