JLSteenwyk / PhyKIT

a UNIX shell toolkit for processing and analyzing multiple sequence alignments and phylogenies
https://jlsteenwyk.com/PhyKIT/
MIT License
60 stars 8 forks source link

ImportError: cannot import name 'false_discovery_control' from 'scipy.stats' #40

Open zhangrengang opened 1 week ago

zhangrengang commented 1 week ago

Hi, I get an ImportError as follows:

$ phykit -h
Traceback (most recent call last):
  File "/bin/phykit", line 6, in <module>
    from phykit.phykit import main
  File "/bin/miniconda3/envs/phytop/lib/python3.10/site-packages/phykit/phykit.py", line 15,
in <module>
    from .services.alignment import (
  File "/bin/miniconda3/envs/phytop/lib/python3.10/site-packages/phykit/services/alignment/__init__.py", line 5, in <module>
    from .compositional_bias_per_site import CompositionalBiasPerSite
  File "/bin/miniconda3/envs/phytop/lib/python3.10/site-packages/phykit/services/alignment/compositional_bias_per_site.py", line 1, in <module>
    from scipy.stats import chisquare, false_discovery_control
ImportError: cannot import name 'false_discovery_control' from 'scipy.stats' (/bin/miniconda3/envs/phytop/lib/python3.10/site-packages/scipy/stats/__init__.py)

$ python -c "import scipy; print(scipy.__version__)"
1.9.3

$ python -V
Python 3.10.8

phykit is installed via conda.

JLSteenwyk commented 1 week ago

Hi @zhangrengang,

Thank you so much for your interest in PhyKIT. I apologize for the trouble with installing via Conda.

The PhyKIT team has decided to let bioconda manage conda installation — see here https://anaconda.org/bioconda/phykit — because more downloads were coming from them than us.

Nonetheless, I would be happy to help you troubleshoot.

Here are two options for a path forward: 1) Try installing via PyPi. This is my personal preference. To do so, you can install PhyKIT in a virtual environment as follows:

# create virtual environment
python -m venv venv
# activate virtual environment
source venv/bin/activate
# install phykit
pip install phykit

2) Please provide all commands that you used to install PhyKIT and we can try and diagnose from there.

Thank you again!

Best,

Jacob

zhangrengang commented 1 week ago

Hi @JLSteenwyk ,

Thank you.

The conda command that I used to install PhyKIT is mamba install phykit -n phytop. The channel bioconda is in the conda config file, so is not specified. In the installation process, scipy was not upgraded.

I have installed phykit via pip, but another error raises:

$ miniconda3/envs/rates/bin/pip install phykit
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting phykit
  Downloading http://mirrors.aliyun.com/pypi/packages/8b/c4/f77024e49d8dbed1d87ff7fa01c74357ece085685ce95aeb65b18fb11c21/phykit-2.0.1-py2.py3-none-any.whl (69 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 69.7/69.7 kB 1.9 MB/s eta 0:00:00
Collecting numpy>=1.24.0
  Downloading http://mirrors.aliyun.com/pypi/packages/b9/14/78635daab4b07c0930c919d451b8bf8c164774e6a3413aed04a6d95758ce/numpy-2.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.5 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19.5/19.5 MB 9.3 MB/s eta 0:00:00
Collecting scikit-learn>=1.4.2
  Downloading http://mirrors.aliyun.com/pypi/packages/2a/9d/d332ec76e2cc442fce98bc43a44e69d3c281e6b4ede6b6db2616dc6fbec6/scikit_learn-1.5.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
(13.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.4/13.4 MB 9.3 MB/s eta 0:00:00
Collecting cython
  Downloading http://mirrors.aliyun.com/pypi/packages/64/42/73859619d9261c2de163f293144064f6df613b0f4e3fcf5cfd0543804f98/Cython-3.0.11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6
MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.6/3.6 MB 8.9 MB/s eta 0:00:00
Collecting scipy>=1.11.3
  Downloading http://mirrors.aliyun.com/pypi/packages/35/f5/d0ad1a96f80962ba65e2ce1de6a1e59edecd1f0a7b55990ed208848012e0/scipy-1.13.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6
MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.6/38.6 MB 8.7 MB/s eta 0:00:00
Requirement already satisfied: biopython>=1.82 in ./miniconda3/envs/rates/lib/python3.9/site-packages (from phykit) (1.84)
Collecting joblib>=1.2.0
  Downloading http://mirrors.aliyun.com/pypi/packages/91/29/df4b9b42f2be0b623cbd5e2140cafcaa2bef0759a00b7b70104dcfe2fb51/joblib-1.4.2-py3-none-any.whl (301 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 301.8/301.8 kB 11.8 MB/s eta 0:00:00
Collecting threadpoolctl>=3.1.0
  Downloading http://mirrors.aliyun.com/pypi/packages/4b/2c/ffbf7a134b9ab11a67b0cf0726453cedd9c5043a4fe7a35d1cefa9a1bcfb/threadpoolctl-3.5.0-py3-none-any.whl (18 kB)
Installing collected packages: threadpoolctl, numpy, joblib, cython, scipy, scikit-learn, phykit
  Attempting uninstall: numpy
    Found existing installation: numpy 1.23.3
    Uninstalling numpy-1.23.3:
      Successfully uninstalled numpy-1.23.3
  Attempting uninstall: scipy
    Found existing installation: scipy 1.9.1
    Uninstalling scipy-1.9.1:
      Successfully uninstalled scipy-1.9.1
Successfully installed cython-3.0.11 joblib-1.4.2 numpy-2.0.2 phykit-2.0.1 scikit-learn-1.5.2 scipy-1.13.1 threadpoolctl-3.5.0

$ miniconda3/envs/rates/bin/phykit -h
Traceback (most recent call last):
  File "/media/40T/wlx/zrg/bin/phykit", line 5, in <module>
    from phykit.phykit import main
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/phykit/phykit.py", line 35, in <module>
    from .services.tree import (
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/phykit/services/tree/__init__.py", line 20, in <module>
    from .saturation import Saturation
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/phykit/services/tree/saturation.py", line 9, in <module>
    from sklearn.linear_model import LinearRegression
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/sklearn/__init__.py", line 84, in <module>
    from .base import clone
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/sklearn/base.py", line 19, in <module>
    from .utils._estimator_html_repr import _HTMLDocumentationLinkMixin, estimator_html_repr
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/sklearn/utils/__init__.py", line 11, in <module>
    from ._chunking import gen_batches, gen_even_slices
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/sklearn/utils/_chunking.py", line 8, in <module>
    from ._param_validation import Interval, validate_params
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/sklearn/utils/_param_validation.py", line 14, in <module>
    from .validation import _is_arraylike_not_scalar
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/sklearn/utils/validation.py", line 26, in <module>
    from ..utils._array_api import _asarray_with_order, _is_numpy_namespace, get_namespace
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/sklearn/utils/_array_api.py", line 11, in <module>
    from .fixes import parse_version
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/sklearn/utils/fixes.py", line 24, in <module>
    import pandas as pd
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/pandas/__init__.py", line 22, in <module>
    from pandas.compat import is_numpy_dev as _is_numpy_dev  # pyright: ignore # noqa:F401
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/pandas/compat/__init__.py", line 18, in <module>
    from pandas.compat.numpy import (
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/pandas/compat/numpy/__init__.py", line 4, in <module>
    from pandas.util.version import Version
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/pandas/util/__init__.py", line 2, in <module>
    from pandas.util._decorators import (  # noqa:F401
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/pandas/util/_decorators.py", line 14, in <module>
    from pandas._libs.properties import cache_readonly
  File "/bin/miniconda3/envs/rates/lib/python3.9/site-packages/pandas/_libs/__init__.py", line 13, in <module>
    from pandas._libs.interval import Interval
  File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
JLSteenwyk commented 6 days ago

Hi @zhangrengang,

Would it be possible to try installing PhyKIT via PyPi in a python environment outside of the conda environment?

best,

Jacob