ksamuk / pixy

Software for painlessly estimating average nucleotide diversity within and between populations
https://pixy.readthedocs.io/
MIT License
115 stars 14 forks source link

Attribute Error During Help Menu Call #80

Closed cizydorczyk closed 9 months ago

cizydorczyk commented 1 year ago

When I simply try to run pixy --help, I get an attribute error:

(pixy-env) conrad@conrad-Precision-Tower-3620:~/les_complete/pi-testing$ pixy --help
Traceback (most recent call last):
  File "/home/conrad/anaconda3/envs/pixy-env/bin/pixy", line 7, in <module>
    from pixy.__main__ import main
  File "/home/conrad/anaconda3/envs/pixy-env/lib/python3.8/site-packages/pixy/__main__.py", line 6, in <module>
    import allel
  File "/home/conrad/anaconda3/envs/pixy-env/lib/python3.8/site-packages/allel/__init__.py", line 5, in <module>
    from .model.chunked import *
  File "/home/conrad/anaconda3/envs/pixy-env/lib/python3.8/site-packages/allel/model/chunked.py", line 24, in <module>
    from allel import chunked as _chunked
  File "/home/conrad/anaconda3/envs/pixy-env/lib/python3.8/site-packages/allel/chunked/__init__.py", line 52, in <module>
    import h5py as _h5py
  File "/home/conrad/anaconda3/envs/pixy-env/lib/python3.8/site-packages/h5py/__init__.py", line 46, in <module>
    from ._conv import register_converters as _register_converters
  File "h5py/h5t.pxd", line 14, in init h5py._conv
  File "h5py/h5t.pyx", line 293, in init h5py.h5t
  File "/home/conrad/anaconda3/envs/pixy-env/lib/python3.8/site-packages/numpy/__init__.py", line 320, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'typeDict'

This is using pixy v1.2.7 and python 3.8 installed in a clean conda environment (with nothing else installed other than dependencies).

Any idea what the problem might be?

cizydorczyk commented 1 year ago

I installed pixy v1.2.6 and it worked just fine with python 3.8. Not sure what the problem is but will update post if I figure it out.

sagitaninta commented 10 months ago

I am also having the exact same issue.

I was trying installing an older version of numpy as suggested by this stackoverflow: https://stackoverflow.com/questions/74852225/attributeerror-module-numpy-has-no-attribute-typedict

But then I got another problem:

Traceback (most recent call last):
  File "/home/mdn487/.conda/envs/pixy_env/bin/pixy", line 7, in <module>
    from pixy.__main__ import main
  File "/home/mdn487/.conda/envs/pixy_env/lib/python3.8/site-packages/pixy/__main__.py", line 6, in <module>
    import allel
  File "/home/mdn487/.conda/envs/pixy_env/lib/python3.8/site-packages/allel/__init__.py", line 4, in <module>
    from .model.ndarray import *
  File "/home/mdn487/.conda/envs/pixy_env/lib/python3.8/site-packages/allel/model/ndarray.py", line 18, in <module>
    from allel.opt.model import genotype_array_pack_diploid, genotype_array_unpack_diploid, \
  File "allel/opt/model.pyx", line 1, in init allel.opt.model
ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use '<void>numpy._import_array' to disable if you are certain you don't need it).

I think this is a dependency issue that needs tinkering in the source code.

Would you want to help us with this @ksamuk ? We cannot use pixy otherwise despite successful conda install :)

ksamuk commented 10 months ago

Hi there, we'll have to watch for a patch, but see this comment here in the meantime: https://github.com/ksamuk/pixy/issues/86

sagitaninta commented 10 months ago

I would like to update that I have upgraded scipy and numpy using pip as it says there:

(pixy_env) [mdn487@scarbpop01fl ~]$ pip install numpy --upgrade
Requirement already satisfied: numpy in ./.conda/envs/pixy_env/lib/python3.8/site-packages (1.21.0)
Collecting numpy
  Downloading numpy-1.24.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.6 kB)
Downloading numpy-1.24.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.3/17.3 MB 54.4 MB/s eta 0:00:00
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 1.21.0
    Uninstalling numpy-1.21.0:
      Successfully uninstalled numpy-1.21.0
Successfully installed numpy-1.24.4
(pixy_env) [mdn487@scarbpop01fl ~]$ pip install scipy --upgrade
Requirement already satisfied: scipy in ./.conda/envs/pixy_env/lib/python3.8/site-packages (1.10.1)
Requirement already satisfied: numpy<1.27.0,>=1.19.5 in ./.conda/envs/pixy_env/lib/python3.8/site-packages (from scipy) (1.24.4)

Then it still does not work.

pixy --help
Traceback (most recent call last):
  File "/home/mdn487/.conda/envs/pixy_env/bin/pixy", line 7, in <module>
    from pixy.__main__ import main
  File "/home/mdn487/.conda/envs/pixy_env/lib/python3.8/site-packages/pixy/__main__.py", line 6, in <module>
    import allel
  File "/home/mdn487/.conda/envs/pixy_env/lib/python3.8/site-packages/allel/__init__.py", line 5, in <module>
    from .model.chunked import *
  File "/home/mdn487/.conda/envs/pixy_env/lib/python3.8/site-packages/allel/model/chunked.py", line 24, in <module>
    from allel import chunked as _chunked
  File "/home/mdn487/.conda/envs/pixy_env/lib/python3.8/site-packages/allel/chunked/__init__.py", line 52, in <module>
    import h5py as _h5py
  File "/home/mdn487/.conda/envs/pixy_env/lib/python3.8/site-packages/h5py/__init__.py", line 46, in <module>
    from ._conv import register_converters as _register_converters
  File "h5py/h5t.pxd", line 14, in init h5py._conv
  File "h5py/h5t.pyx", line 293, in init h5py.h5t
  File "/home/mdn487/.conda/envs/pixy_env/lib/python3.8/site-packages/numpy/__init__.py", line 320, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'typeDict'
ksamuk commented 9 months ago

Hi There,

We are working on a fix for this, in the meantime, this might work for you:

conda remove -n pixy --all
conda create --name pixy -c anaconda python=3.8.17
conda activate pixy
conda install -c conda-forge pixy
conda install -c bioconda htslib
pip install numpy --upgrade
python -m pip install --user --upgrade h5py