Skip to content

Fix ImportError for scipy 1.8.0

See

Currently, it gives the following error message:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [29], in <module>
----> 1 from scipy.sparse.linalg import linsolve

ImportError: cannot import name 'linsolve' from 'scipy.sparse.linalg' (/nfshome/basnijholt/mambaforge/envs/qms-lab-20220224-main/lib/python3.9/site-packages/scipy/sparse/linalg/__init__.py)

With this change, the following warning is emitted:

/tmp/scratch/basnijholt/ipykernel_59547/2794395227.py:1: DeprecationWarning: The module `scipy.sparse.linalg.dsolve.linsolve` is deprecated. All public names must be imported directly from the `scipy.sparse.linalg` namespace.
  from scipy.sparse.linalg.dsolve import linsolve

The following gives no warning:

from scipy.sparse.linalg._dsolve import linsolve

However, we should reconsider using private features.

Merge request reports