biobakery / MetaPhlAn

MetaPhlAn is a computational tool for profiling the composition of microbial communities from metagenomic shotgun sequencing data
http://segatalab.cibio.unitn.it/tools/metaphlan/index.html
MIT License
301 stars 86 forks source link

[BUG] MetaPhlAn 4.0.4 h5py/numpy version issue #197

Closed sjaenick closed 1 year ago

sjaenick commented 1 year ago

Describe the bug

MetaPhlAn 4.0.4 seems to have an issue related to h5py/numpy; I'm not sure if the issue is already present in previous MetaPhlAn releases since I only tested 4.0.4.

[sjaenick@hp-dl560:~ ]$ /vol/mgx-sw/bin/metaphlan --nproc 1 --offline   -t reads_map   --no_map   --bowtie2db /vol/biodb/local_databases/MGX/MetaPhlAn4/   --bowtie2_exe /vol/mgx-sw/bin/bowtie2   --input_type fastq   ~/testdata.fq -o ~/testdata.m4.out
Traceback (most recent call last):
  File "/vol/mgx-sw/bin/metaphlan", line 5, in <module>
    from metaphlan.metaphlan import main
  File "/vol/mgx-sw/lib/python3.11/site-packages/metaphlan/metaphlan.py", line 54, in <module>
    import biom
  File "/vol/mgx-sw/lib/python3.11/site-packages/biom_format-2.1.14-py3.11-linux-x86_64.egg/biom/__init__.py", line 51, in <module>
    from .table import Table
  File "/vol/mgx-sw/lib/python3.11/site-packages/biom_format-2.1.14-py3.11-linux-x86_64.egg/biom/table.py", line 190, in <module>
    from biom.util import (get_biom_format_version_string,
  File "/vol/mgx-sw/lib/python3.11/site-packages/biom_format-2.1.14-py3.11-linux-x86_64.egg/biom/util.py", line 25, in <module>
    import h5py
  File "/vol/mgx-sw/lib/python3.11/site-packages/h5py/__init__.py", line 46, in <module>
    from ._conv import register_converters as _register_converters
  File "h5py/_conv.pyx", line 1, in init h5py._conv
  File "h5py/h5t.pyx", line 293, in init h5py.h5t
  File "/vol/mgx-sw/lib/python3.11/site-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'typeDict'

To Reproduce

Ubuntu 20.04.5 LTS with Python 3.11 (compiled from source), installation was done as follows:

VERSION=4.0.4
wget -q https://github.com/biobakery/MetaPhlAn/archive/refs/tags/${VERSION}.tar.gz
tar xzf ${VERSION}.tar.gz
rm ${VERSION}.tar.gz
cd MetaPhlAn-${VERSION}
pip3 install .
cd ..
rm -rf MetaPhlAn-${VERSION}
$ pip3 list
Package                  Version
------------------------ ------------------
argcomplete              2.0.0
bagit                    1.8.1
bcbio-gff                0.6.9
biom-format              2.1.14
biopython                1.80
CacheControl             0.12.11
certifi                  2022.12.7
charset-normalizer       3.0.1
click                    8.1.3
click                    8.1.3
CMSeq                    1.0.4
coloredlogs              15.0.1
concoct                  1.1.0
concoct                  1.1.0
contourpy                1.0.7
cwl-upgrader             1.2.4
cwl-utils                0.21
cwltool                  3.1.20221201130942
cycler                   0.11.0
Cython                   0.29.33
DendroPy                 4.5.2
fonttools                4.38.0
gtdbtk                   2.1.1
h5py                     2.10.0
hclust2                  1.0.0
humanfriendly            10.0
idna                     3.4
isal                     1.1.0
isodate                  0.6.1
joblib                   1.2.0
kiwisolver               1.4.4
lightgbm                 3.3.4
lockfile                 0.12.2
lxml                     4.9.2
matplotlib               3.6.3
MetaPhlAn                4.0.4
mistune                  2.0.4
msgpack                  1.0.4
mypy-extensions          0.4.3
networkx                 2.8.8
nose                     1.3.7
numpy                    1.24.1
nvidia-cublas-cu11       11.10.3.66
nvidia-cuda-nvrtc-cu11   11.7.99
nvidia-cuda-runtime-cu11 11.7.99
nvidia-cudnn-cu11        8.5.0.96
packaging                23.0
pandas                   1.5.2
PhyloPhlAn               3.0.3
Pillow                   9.4.0
pip                      22.3.1
pprodigal                1.0.1
prov                     1.5.1
psutil                   5.9.4
pydot                    1.4.2
pyparsing                3.0.9
pysam                    0.20.0
python-dateutil          2.8.2
pytz                     2022.7.1
PyYAML                   6.0
PyYAML                   6.0
rdflib                   6.2.0
requests                 2.28.2
ruamel.yaml              0.17.21
schema-salad             8.3.20230109181936
scikit-learn             1.2.0
scipy                    1.10.0
seaborn                  0.12.2
setuptools               66.0.0
shellescape              3.8.1
six                      1.16.0
threadpoolctl            3.1.0
torch                    1.13.1
tqdm                     4.64.1
typing_extensions        4.4.0
urllib3                  1.26.14
wheel                    0.38.4

I manually purged some packages, deleted the pip cache and reinstalled MetaPhlAn:

pip3 uninstall h5py biom-format numpy MetaPhlAn
rm -rf ~/.cache/pip/
(reinstall MetaPhlAn as above)

and ended up with a working MetaPhlAn installation with the following dependencies:

h5py                     3.7.0
biom-format              2.1.14
numpy                    1.24.1

Please note same versions for biom-format and numpy, but a different major release version for h5py'; I'm not exactly a Python person, but maybe MetaPhlAn should require a minimum version for the h5py dependency.

github-actions[bot] commented 1 year ago

Thank you for creating this issue. We currently field issues through our bioBakery Discourse Support Forum. If you would please post the issue to discourse we would be happy to sync up with you to get it resolved.