xryanglab / RiboCode

release version
MIT License
46 stars 15 forks source link

ModuleNotFoundError: No module named 'fasta' #53

Open fulaibaowang opened 1 year ago

fulaibaowang commented 1 year ago

Hi, I got a ModuleNotFoundError when testing the RiboCode installation with RiboCode_onestep -V Can you help?

$ RiboCode_onestep -V
Traceback (most recent call last):
  File "/nexus/posix0/MAGE-flaski/service/projects/data/Bioinformatics/bit_pipe_ribosome_profiling/libraries/venv3/bin/RiboCode_onestep", line 5, in <module>
    from RiboCode.RiboCode_onestep import main
  File "/nexus/posix0/MAGE-flaski/service/projects/data/Bioinformatics/bit_pipe_ribosome_profiling/libraries/venv3/lib/python3.9/site-packages/RiboCode/RiboCode_onestep.py", line 16, in <module>
    from .prepare_transcripts import *
  File "/nexus/posix0/MAGE-flaski/service/projects/data/Bioinformatics/bit_pipe_ribosome_profiling/libraries/venv3/lib/python3.9/site-packages/RiboCode/prepare_transcripts.py", line 17, in <module>
    from pyfasta import Fasta
  File "/nexus/posix0/MAGE-flaski/service/projects/data/Bioinformatics/bit_pipe_ribosome_profiling/libraries/venv3/lib/python3.9/site-packages/pyfasta/__init__.py", line 3, in <module>
    from fasta import Fasta, complement, DuplicateHeaderException
ModuleNotFoundError: No module named 'fasta'

my package list

$ pip3 list
Package            Version
------------------ ---------
AGEpy              0.8.2
autopaths          1.6.0
bcrypt             3.2.0
biomart            0.9.2
biopython          1.78
certifi            2020.12.5
cffi               1.14.5
chardet            4.0.0
charset-normalizer 3.1.0
click              7.1.2
coloredlogs        15.0
colormath          3.0.0
cryptography       3.4.6
cycler             0.10.0
decorator          4.4.2
et-xmlfile         1.0.1
future             0.18.2
h5py               3.1.0
HTSeq              0.13.5
humanfriendly      9.1
idna               2.10
ipaddress          1.0.23
jdcal              1.4.1
Jinja2             2.11.3
joblib             1.0.1
kiwisolver         1.3.1
lzstring           1.0.4
Markdown           3.3.4
MarkupSafe         1.1.1
matplotlib         3.3.4
minepy             1.2.6
multiqc            1.9
networkx           2.5
numpy              1.20.1
openpyxl           3.0.6
pandas             1.2.2
paramiko           2.7.2
patsy              0.5.1
Pillow             8.1.0
pip                23.0.1
plumbing           2.11.2
py                 1.11.0
pybedtools         0.8.1
pycparser          2.20
pyfasta            0.5.2
PyNaCl             1.4.0
pyparsing          2.4.7
pysam              0.16.0.1
python-dateutil    2.8.1
pytz               2021.1
PyYAML             5.4.1
requests           2.25.1
retry              0.9.2
RiboCode           1.2.15
scikit-learn       0.24.1
scipy              1.6.1
seaborn            0.11.1
setuptools         57.5.0
sh                 2.0.3
simplejson         3.17.2
six                1.15.0
spectra            0.0.11
statsmodels        0.12.2
suds-jurko         0.6
threadpoolctl      2.1.0
tqdm               4.65.0
urllib3            1.26.3
Wand               0.6.5
wheel              0.38.4
xlrd               2.0.1
XlsxWriter         1.3.7
ckvilas commented 1 year ago

I received the same error. Any tips? Thank you in advance! @zhengtaoxiao

ckvilas commented 1 year ago

Update: uninstalling and re-installing fasta and Pyfasta solved the issue.

erlun1 commented 11 months ago

RiboCode uses pyfasta instead of the updated version pyfaidx, so I browsed through the source code of pyfasta and found that in the init.py file, the code from fasta import Fasta, complement, DuplicateHeaderException is actually intended to call the fasta.py script in the same directory, rather than importing a module named fasta. If necessary, you can manually modify the init.py file and then install it.

erlun1 commented 11 months ago

additionally,"pyfasta" requires Python 2, while "RiboCode" requires Python 3.6 or above.So: In fasta.py, for Python 3.10 and above, from collections import Mapping should be changed to from collections.abc import Mapping. In records.py, for Python 3.X, import cPickle should be changed to import _pickle as cPickle, and the long type should be removed. In split_fasta.py, for Python 3.X, from cStringIO import StringIO should be changed to from io import StringIO.

seeninheoi commented 4 months ago

additionally,"pyfasta" requires Python 2, while "RiboCode" requires Python 3.6 or above.So: In fasta.py, for Python 3.10 and above, from collections import Mapping should be changed to from collections.abc import Mapping. In records.py, for Python 3.X, import cPickle should be changed to import _pickle as cPickle, and the long type should be removed. In split_fasta.py, for Python 3.X, from cStringIO import StringIO should be changed to from io import StringIO.

Hello,I can't exactly understand the step how to solve with it. How to instead the python2 to python3 in fasta? can you give me some more detail suggestions,thank you so much┭┮﹏┭┮

pavelToman commented 2 months ago

For me helped:

sed -i
    -e 's/from fasta/from pyfasta.fasta/'
    -e 's/from records/from pyfasta.records/'
    -e 's/from split_fasta/from pyfasta.split_fasta/'
    pyfasta/__init__.py &&
sed -i 's/from collections/from collections.abc/' pyfasta/fasta.py &&
sed -i 's/from records/from pyfasta.records/' pyfasta/fasta.py &&
sed -i 's/import cPickle/import _pickle as cPickle/' pyfasta/records.py &&
sed -i 's/from cStringIO import StringIO/from io import StringIO/' pyfasta/split_fasta.py &&