GeoStat-Framework / PyKrige

Kriging Toolkit for Python
https://pykrige.readthedocs.io
BSD 3-Clause "New" or "Revised" License
758 stars 188 forks source link

Incompatible with SciPy 1.9.0, AttributeError on scipy.linalg.pinv2 #236

Closed bmag closed 2 years ago

bmag commented 2 years ago

SciPy released version 1.9.0 three days ago, and in that version they removed scipy.linalg.pinv2 [1]. Latest PyKrige (version 1.6.1) tries to access this function at import time, causing an AttributeError. According to SciPy 1.7.0 release notes, scipy.linalg.pinv can replace the usage of scipy.linalg.pinv2 [2].

Steps to reproduce:

  1. Create a new virtual environment, activate it, and install PyKrige:
    python -m venv new_env
    . new_env/bin/activate
    python -m pip install pykrige
  2. Run python and try to import pykrige: python -c 'import pykrige'

Result:

$ python -c 'import pykrige'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/path-to-new_env/lib/python3.10/site-packages/pykrige/__init__.py", line 45, in <module>
    from .ok import OrdinaryKriging  # noqa
  File "/path-to-new_env/lib/python3.10/site-packages/pykrige/ok.py", line 28, in <module>
    from . import core
  File "/path-to-new_env/lib/python3.10/site-packages/pykrige/core.py", line 34, in <module>
    P_INV = {"pinv": spl.pinv, "pinv2": spl.pinv2, "pinvh": spl.pinvh}
AttributeError: module 'scipy.linalg' has no attribute 'pinv2'. Did you mean: 'pinv'?
$ pip list
Package    Version
---------- -------
numpy      1.23.1
pip        22.0.2
PyKrige    1.6.1
scipy      1.9.0
setuptools 59.6.0

[1] https://docs.scipy.org/doc/scipy/release.1.9.0.html#expired-deprecations [2] https://docs.scipy.org/doc/scipy/release.1.7.0.html#scipy-linalg-deprecations

jreniel commented 2 years ago

Came here with exactly this same problem. A temporary fix is to downgrade scipy to version 1.5.4.

jreniel commented 2 years ago

@MuellerSeb Thanks for fixing this! =)