ImportError: cannot import name 'triu' from 'scipy.linalg' (or 'simps', 'imread', any name): which SciPy removed it and what to use
SciPy 1.13.0 (2024-04-02) removed scipy.linalg.triu, tril and tri (use numpy.triu), which breaks gensim 4.3.2 and earlier; 1.14.0 (2024-06-24) removed scipy.integrate.simps, trapz, cumtrapz (use simpson, trapezoid, cumulative_trapezoid) and the sparse .A (use .toarray()); 1.3.0 removed scipy.misc.imread and imresize (use imageio or Pillow). If the error comes from a library you did not write, upgrade the library or pin SciPy below the release that removed the name. Paste the error below for the release-by-release answer.
Examples:
Runs in your browser on the data in this page (scipy_names.json); nothing you paste is sent anywhere.
Which release removed it, and what replaces it?
117 public names of SciPy's submodules and sparse matrix classes that one release has and a later one does not, plus 577 NumPy names the scipy namespace used to re-export (539 of them removed in 1.12.0; the lookup answers for each). "Instead" is SciPy's own deprecation text from the last release that had the name (75 of 117); for 19 more it names the module that still has the same name in 1.18.1.
| Name | Removed in | Instead |
|---|---|---|
scipy.misc.bytescale | 1.3.0 | `bytescale` is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. |
scipy.misc.comb | 1.3.0 | Importing `comb` from scipy.misc is deprecated in scipy 1.0.0. Use `scipy.special.comb` instead. |
scipy.misc.factorial | 1.3.0 | Importing `factorial` from scipy.misc is deprecated in scipy 1.0.0. Use `scipy.special.factorial` instead. |
scipy.misc.factorial2 | 1.3.0 | Importing `factorial2` from scipy.misc is deprecated in scipy 1.0.0. Use `scipy.special.factorial2` instead. |
scipy.misc.factorialk | 1.3.0 | Importing `factorialk` from scipy.misc is deprecated in scipy 1.0.0. Use `scipy.special.factorialk` instead. |
scipy.misc.fromimage | 1.3.0 | `fromimage` is deprecated in SciPy 1.0.0. and will be removed in 1.2.0. Use ``np.asarray(im)`` instead. |
scipy.misc.imfilter | 1.3.0 | `imfilter` is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use Pillow filtering functionality directly. |
scipy.misc.imread | 1.3.0 | `imread` is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use ``imageio.imread`` instead. |
scipy.misc.imresize | 1.3.0 | `imresize` is deprecated in SciPy 1.0.0, and will be removed in 1.3.0. Use Pillow instead: ``numpy.array(Image.fromarray(arr).resize())``. |
scipy.misc.imrotate | 1.3.0 | `imrotate` is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use ``skimage.transform.rotate`` instead. |
scipy.misc.imsave | 1.3.0 | `imsave` is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use ``imageio.imwrite`` instead. |
scipy.misc.imshow | 1.3.0 | `imshow` is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use ``matplotlib.pyplot.imshow`` instead. |
scipy.misc.logsumexp | 1.3.0 | Importing `logsumexp` from scipy.misc is deprecated in scipy 1.0.0. Use `scipy.special.logsumexp` instead. |
scipy.misc.toimage | 1.3.0 | `toimage` is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use Pillow's ``Image.fromarray`` directly instead. |
scipy.special.bessel_diff_formula | 1.4.0 | |
scipy.special.hyp1f2 | 1.4.0 | hyp1f2 is deprecated in SciPy 1.2 |
scipy.special.hyp2f0 | 1.4.0 | hyp2f0 is deprecated in SciPy 1.2 |
scipy.special.hyp3f0 | 1.4.0 | hyp3f0 is deprecated in SciPy 1.2 |
scipy.linalg.linalg_version | 1.5.0 | |
scipy.odr.add_newdocs | 1.5.0 | |
scipy.signal.slepian | 1.6.0 | slepian is deprecated and will be removed in a future version, use dpss instead |
scipy.signal.windows.slepian | 1.6.0 | slepian is deprecated and will be removed in a future version, use dpss instead |
scipy.stats.frechet_l | 1.6.0 | The distribution `frechet_l` is a synonym for `weibull_max`; this historical usage is deprecated because of possible confusion with the (quite different) Frechet distribution. To preserve the existing behavior of the program, use `scipy.stats.weibull_max`. For the Frechet distribution (i.e. the Type II extreme value distribution), use `scipy.stats.invweibull`. |
scipy.stats.frechet_r | 1.6.0 | The distribution `frechet_r` is a synonym for `weibull_min`; this historical usage is deprecated because of possible confusion with the (quite different) Frechet distribution. To preserve the existing behavior of the program, use `scipy.stats.weibull_min`. For the Frechet distribution (i.e. the Type II extreme value distribution), use `scipy.stats.invweibull`. |
scipy.io.byteordercodes | 1.8.0 | |
scipy.signal.sigtools | 1.8.0 | |
scipy.sparse.linalg.arpack | 1.8.0 | |
scipy.sparse.linalg.iterative | 1.8.0 | |
scipy.sparse.linalg.linsolve | 1.8.0 | |
scipy.sparse.linalg.utils | 1.8.0 | |
scipy.spatial.distance.wminkowski | 1.8.0 | scipy.distance.wminkowski is deprecated and will be removed in SciPy 1.8.0, use scipy.distance.minkowski instead. |
scipy.integrate.quad_explain | 1.9.0 | |
scipy.linalg.pinv2 | 1.9.0 | scipy.linalg.pinv2 is deprecated since SciPy 1.7.0, use scipy.linalg.pinv instead |
scipy.signal.hanning | 1.9.0 | |
scipy.signal.windows.hanning | 1.9.0 | |
scipy.spatial.distance.matching | 1.9.0 | spatial.distance.matching is deprecated in scipy 1.0.0; use spatial.distance.hamming instead. |
scipy.stats.BootstrapDegenerateDistributionWarning | 1.9.0 | |
scipy.stats.F_onewayBadInputSizesWarning | 1.9.0 | |
scipy.stats.F_onewayConstantInputWarning | 1.9.0 | |
scipy.stats.itemfreq | 1.9.0 | `itemfreq` is deprecated and will be removed in a future version. Use instead `np.unique(..., return_counts=True)` |
scipy.stats.median_absolute_deviation | 1.9.0 | |
scipy.stats.PearsonRConstantInputWarning | 1.9.0 | |
scipy.stats.PearsonRNearConstantInputWarning | 1.9.0 | |
scipy.stats.SpearmanRConstantInputWarning | 1.9.0 | |
scipy.stats.NumericalInverseHermite | 1.10.0 | NumericalInverseHermite has been deprecated from `scipy.stats` and will be removed in SciPy 1.10.0. To use `NumericalInverseHermite`, import/use it from `scipy.stats.sampling` module instead. i.e. `from scipy.stats.sampling import NumericalInverseHermite` |
scipy.spatial.distance.kulsinski | 1.11.1 | Kulsinski has been deprecated from scipy.spatial.distance in SciPy 1.9.0 and it will be removed in SciPy 1.11.0. It is superseded by scipy.spatial.distance.kulczynski1. |
scipy.stats.gilbrat | 1.11.1 | `gilbrat` is deprecated, use `gibrat` instead! |
scipy.stats.binom_test | 1.12.0 | 'binom_test' is deprecated in favour of 'binomtest' from version 1.7.0 and will be removed in Scipy 1.12.0. |
scipy.stats.statlib | 1.12.0 | scipy.stats.statlib is deprecated and has no attribute |
scipy.linalg.flinalg | 1.13.0 | |
scipy.linalg.tri | 1.13.0 | 'tri'/'tril/'triu' are deprecated as of SciPy 1.11.0 and will be removed in v1.13.0. Please use numpy.(tri/tril/triu) instead. |
scipy.linalg.tril | 1.13.0 | 'tri'/'tril/'triu' are deprecated as of SciPy 1.11.0 and will be removed in v1.13.0. Please use numpy.(tri/tril/triu) instead. |
scipy.linalg.triu | 1.13.0 | 'tri'/'tril/'triu' are deprecated as of SciPy 1.11.0 and will be removed in v1.13.0. Please use numpy.(tri/tril/triu) instead. |
scipy.signal.barthann | 1.13.0 | From scipy.signal.windows import barthann (still there in 1.18.1). |
scipy.signal.bartlett | 1.13.0 | From scipy.signal.windows import bartlett (still there in 1.18.1). |
scipy.signal.blackman | 1.13.0 | From scipy.signal.windows import blackman (still there in 1.18.1). |
scipy.signal.blackmanharris | 1.13.0 | From scipy.signal.windows import blackmanharris (still there in 1.18.1). |
scipy.signal.bohman | 1.13.0 | From scipy.signal.windows import bohman (still there in 1.18.1). |
scipy.signal.boxcar | 1.13.0 | From scipy.signal.windows import boxcar (still there in 1.18.1). |
scipy.signal.bspline | 1.13.0 | `scipy.signal.bspline` is deprecated in SciPy 1.11 and will be removed in SciPy 1.13. The exact equivalent (for a float array `x`) is >>> from scipy.interpolate import BSpline >>> knots = np.arange(-(n+1)/2, (n+3)/2) >>> out = BSpline.basis_element(knots)(x) >>> out[(x < knots[0]) | (x > knots[-1])] = 0.0 |
scipy.signal.chebwin | 1.13.0 | From scipy.signal.windows import chebwin (still there in 1.18.1). |
scipy.signal.cosine | 1.13.0 | From scipy.signal.windows import cosine (still there in 1.18.1). |
scipy.signal.cubic | 1.13.0 | `scipy.signal.cubic` is deprecated in SciPy 1.11 and will be removed in SciPy 1.13. The exact equivalent (for a float array `x`) is >>> from scipy.interpolate import BSpline >>> out = BSpline.basis_element([-2, -1, 0, 1, 2])(x) >>> out[(x < -2 | (x > 2)] = 0.0 |
scipy.signal.exponential | 1.13.0 | From scipy.odr import exponential (still there in 1.18.1). |
scipy.signal.flattop | 1.13.0 | From scipy.signal.windows import flattop (still there in 1.18.1). |
scipy.signal.gaussian | 1.13.0 | From scipy.signal.windows import gaussian (still there in 1.18.1). |
scipy.signal.general_gaussian | 1.13.0 | From scipy.signal.windows import general_gaussian (still there in 1.18.1). |
scipy.signal.hamming | 1.13.0 | From scipy.signal.windows import hamming (still there in 1.18.1). |
scipy.signal.hann | 1.13.0 | From scipy.signal.windows import hann (still there in 1.18.1). |
scipy.signal.impulse2 | 1.13.0 | impulse2 is deprecated and will be removed from scipy 1.13. Use the feature-equivalent impulse function. |
scipy.signal.kaiser | 1.13.0 | From scipy.signal.windows import kaiser (still there in 1.18.1). |
scipy.signal.lsim2 | 1.13.0 | lsim2 is deprecated and will be removed from scipy 1.13. Use the feature-equivalent lsim function. |
scipy.signal.nuttall | 1.13.0 | From scipy.signal.windows import nuttall (still there in 1.18.1). |
scipy.signal.parzen | 1.13.0 | From scipy.signal.windows import parzen (still there in 1.18.1). |
scipy.signal.quadratic | 1.13.0 | `scipy.signal.quadratic` is deprecated in SciPy 1.11 and will be removed in SciPy 1.13. The exact equivalent (for a float array `x`) is >>> from scipy.interpolate import BSpline >>> out = BSpline.basis_element([-1.5, -0.5, 0.5, 1.5])(x) >>> out[(x < -1.5 | (x > 1.5)] = 0.0 |
scipy.signal.step2 | 1.13.0 | step2 is deprecated and will be removed from scipy 1.13. Use the feature-equivalent step function. |
scipy.signal.triang | 1.13.0 | From scipy.signal.windows import triang (still there in 1.18.1). |
scipy.signal.tukey | 1.13.0 | From scipy.signal.windows import tukey (still there in 1.18.1). |
scipy.integrate.cumtrapz | 1.14.0 | 'scipy.integrate.cumtrapz' is deprecated in favour of 'scipy.integrate.cumulative_trapezoid' and will be removed in SciPy 1.14.0 |
scipy.integrate.simps | 1.14.0 | 'scipy.integrate.simps' is deprecated in favour of 'scipy.integrate.simpson' and will be removed in SciPy 1.14.0 |
scipy.integrate.trapz | 1.14.0 | 'scipy.integrate.trapz' is deprecated in favour of 'scipy.integrate.trapezoid' and will be removed in SciPy 1.14.0 |
scipy.interpolate.dfitpack | 1.14.0 | |
scipy.sparse.coo_matrix.A | 1.14.0 | `.A` is deprecated and will be removed in v1.14.0. Use `.toarray()` instead. |
scipy.sparse.coo_matrix.H | 1.14.0 | `.H` is deprecated and will be removed in v1.14.0. Please use `.T.conjugate()` instead. |
scipy.sparse.csr_matrix.A | 1.14.0 | `.A` is deprecated and will be removed in v1.14.0. Use `.toarray()` instead. |
scipy.sparse.csr_matrix.H | 1.14.0 | `.H` is deprecated and will be removed in v1.14.0. Please use `.T.conjugate()` instead. |
scipy.sparse.lil_matrix.A | 1.14.0 | `.A` is deprecated and will be removed in v1.14.0. Use `.toarray()` instead. |
scipy.sparse.lil_matrix.H | 1.14.0 | `.H` is deprecated and will be removed in v1.14.0. Please use `.T.conjugate()` instead. |
scipy.integrate.AccuracyWarning | 1.15.0 | |
scipy.integrate.quadrature | 1.15.0 | `scipy.integrate.quadrature` is deprecated as of SciPy 1.12.0and will be removed in SciPy 1.15.0. Please use`scipy.integrate.quad` instead. |
scipy.integrate.romberg | 1.15.0 | `scipy.integrate.romberg` is deprecated as of SciPy 1.12.0and will be removed in SciPy 1.15.0. Please use`scipy.integrate.quad` instead. |
scipy.misc.ascent | 1.15.0 | scipy.misc.ascent has been deprecated in SciPy v1.10.0; and will be completely removed in SciPy v1.12.0. Dataset methods have moved into the scipy.datasets module. Use scipy.datasets.ascent instead. |
scipy.misc.central_diff_weights | 1.15.0 | scipy.misc.central_diff_weights is deprecated in SciPy v1.10.0; and will be completely removed in SciPy v1.12.0. You may consider using findiff: https://github.com/maroba/findiff or numdifftools: https://github.com/pbrod/numdifftools |
scipy.misc.derivative | 1.15.0 | scipy.misc.derivative is deprecated in SciPy v1.10.0; and will be completely removed in SciPy v1.12.0. You may consider using findiff: https://github.com/maroba/findiff or numdifftools: https://github.com/pbrod/numdifftools |
scipy.misc.electrocardiogram | 1.15.0 | scipy.misc.electrocardiogram has been deprecated in SciPy v1.10.0; and will be completely removed in SciPy v1.12.0. Dataset methods have moved into the scipy.datasets module. Use scipy.datasets.electrocardiogram instead. |
scipy.misc.face | 1.15.0 | scipy.misc.face has been deprecated in SciPy v1.10.0; and will be completely removed in SciPy v1.12.0. Dataset methods have moved into the scipy.datasets module. Use scipy.datasets.face instead. |
scipy.signal.cascade | 1.15.0 | scipy.signal.cascade is deprecated in SciPy 1.12 and will be removed in SciPy 1.15. We recommend using PyWavelets instead. |
scipy.signal.cmplx_sort | 1.15.0 | cmplx_sort was deprecated in SciPy 1.12 and will be removed in SciPy 1.15. The exact equivalent for a numpy array argument is >>> def cmplx_sort(p): ... idx = np.argsort(abs(p)) ... return np.take(p, idx, 0), idx |
scipy.signal.cwt | 1.15.0 | scipy.signal.cwt is deprecated in SciPy 1.12 and will be removed in SciPy 1.15. We recommend using PyWavelets instead. |
scipy.signal.daub | 1.15.0 | scipy.signal.daub is deprecated in SciPy 1.12 and will be removed in SciPy 1.15. We recommend using PyWavelets instead. |
scipy.signal.morlet | 1.15.0 | scipy.signal.morlet is deprecated in SciPy 1.12 and will be removed in SciPy 1.15. We recommend using PyWavelets instead. |
scipy.signal.morlet2 | 1.15.0 | scipy.signal.morlet2 is deprecated in SciPy 1.12 and will be removed in SciPy 1.15. We recommend using PyWavelets instead. |
scipy.signal.qmf | 1.15.0 | scipy.signal.qmf is deprecated in SciPy 1.12 and will be removed in SciPy 1.15. We recommend using PyWavelets instead. |
scipy.signal.ricker | 1.15.0 | scipy.signal.ricker is deprecated in SciPy 1.12 and will be removed in SciPy 1.15. We recommend using PyWavelets instead. |
scipy.special.btdtr | 1.15.0 | This function was deprecated in SciPy 1.12.0, and will be removed in SciPy 1.14.0. Use scipy.special.btdtr instead. |
scipy.special.btdtri | 1.15.0 | This function was deprecated in SciPy 1.12.0, and will be removed in SciPy 1.14.0. Use scipy.special.btdtri instead. |
scipy.stats.rvs_ratio_uniforms | 1.15.0 | Please use `RatioUniforms` from the `scipy.stats.sampling` namespace. The `scipy.stats.rvs_ratio_uniforms` namespace is deprecated and will be removed in SciPy 1.15.0 |
scipy.stats.sampling | 1.15.0 | Please use `RatioUniforms` from the `scipy.stats.sampling` namespace. The `scipy.stats.rvs_ratio_uniforms` namespace is deprecated and will be removed in SciPy 1.15.0 |
scipy.stats.trapz | 1.16.0 | `trapz` is deprecated in favour of `trapezoid` and will be removed in SciPy 1.16.0. |
scipy.linalg.kron | 1.17.0 | `kron` has been deprecated in favour of `numpy.kron` in SciPy 1.15.0 and will be removed in SciPy 1.17.0. |
scipy.spatial.distance.kulczynski1 | 1.17.0 | The kulczynski1 metric is deprecated since SciPy 1.15.0 and will be removed in SciPy 1.17.0. Replace usage of 'kulczynski1(u, v)' with '1/jaccard(u, v) - 1'. |
scipy.spatial.distance.sokalmichener | 1.17.0 | The sokalmichener metric is deprecated since SciPy 1.15.0 and will be removed in SciPy 1.17.0. Replace usage of 'sokalmichener(u, v)' with 'rogerstanimoto(u, v)'. |
scipy.special.clpmn | 1.17.0 | `scipy.special.clpmn` is deprecated as of SciPy 1.15.0 and will be removed in SciPy 1.17.0. |
scipy.special.lpmn | 1.17.0 | `scipy.special.lpmn` is deprecated as of SciPy 1.15.0 and will be removed in SciPy 1.17.0. |
scipy.special.lpn | 1.17.0 | `scipy.special.lpn` is deprecated as of SciPy 1.15.0 and will be removed in SciPy 1.17.0. |
scipy.special.sph_harm | 1.17.0 | |
scipy.stats.find_repeats | 1.17.0 | `scipy.stats.find_repeats` is deprecated as of SciPy 1.15.0 and will be removed in SciPy 1.17.0. Please use `numpy.unique`/`numpy.unique_counts` instead. |
How was this measured?
Each of 17 SciPy releases (the first of every minor from 1.3.3, plus the latest) was installed from PyPI in its own environment, the public names of scipy, 27 submodules and the sparse matrix classes were listed with dir() and __all__, and getattr was run for the union of all names in every release. Releases: 1.3.3 (Python 3.8, NumPy 1.17.5), 1.4.0 (Python 3.8, NumPy 1.18.5), 1.5.0 (Python 3.8, NumPy 1.19.5), 1.6.0 (Python 3.9, NumPy 1.19.5), 1.7.0 (Python 3.9, NumPy 1.21.6), 1.8.0 (Python 3.10, NumPy 1.22.4), 1.9.0 (Python 3.10, NumPy 1.23.5), 1.10.0 (Python 3.11, NumPy 1.24.4), 1.11.1 (Python 3.11, NumPy 1.25.2), 1.12.0 (Python 3.12, NumPy 1.26.4), 1.13.0 (Python 3.12, NumPy 1.26.4), 1.14.0 (Python 3.12, NumPy 2.0.2), 1.15.0 (Python 3.12, NumPy 2.2.6), 1.16.0 (Python 3.12, NumPy 2.5.5), 1.17.0 (Python 3.12, NumPy 2.5.5), 1.18.0 (Python 3.12, NumPy 2.5.5), 1.18.1 (Python 3.12, NumPy 2.5.5). A name counts when it is in the module's __all__ (or the module has none), so modules a file merely imported (np, warnings) are left out. The replacement text is read from the installed source of the last release that had the name: the strings of its deprecation decorator or warnings.warn call, or another deprecation string in SciPy that names it. The scipy.misc image functions and re-exports removed in 1.3.0 were read from the source at the v1.2.0 and v1.3.0 tags. scipy.fft did not exist in 1.3.3.
Patch releases were not read: a name removed in x.y.1 shows at the next minor.
Questions
How do I fix "cannot import name 'triu' from 'scipy.linalg'" (gensim)?
SciPy 1.13.0 (2024-04-02) removed scipy.linalg.tri, tril and triu; 1.11 and 1.12 warned. Use numpy.triu, numpy.tril and numpy.tri, which take the same arguments. gensim 4.3.2 and earlier import triu from scipy.linalg in gensim/matutils.py and fail on import; gensim 4.3.3 (2024-07-19) takes it from numpy. Upgrade gensim, or pin scipy<1.13.
How do I fix "cannot import name 'simps' from 'scipy.integrate'"?
SciPy 1.14.0 (2024-06-24) removed simps, trapz and cumtrapz. Use scipy.integrate.simpson, trapezoid and cumulative_trapezoid.
How do I fix "'csr_matrix' object has no attribute 'A'"?
SciPy 1.14.0 removed the .A and .H attributes of the sparse matrix classes. Use .toarray() for .A and .T.conjugate() (or .conj().T) for .H.
How do I fix "cannot import name 'imread' from 'scipy.misc'"?
SciPy 1.3.0 (2019-05-17) removed the image functions of scipy.misc (imread, imsave, imresize, imrotate, imshow, toimage, fromimage, bytescale, imfilter); 1.2.3 is the last release with them, and they needed Pillow. Read and write images with imageio (imageio.imread) or Pillow; resize with Pillow's Image.resize. The same release removed misc.comb, factorial and logsumexp: import them from scipy.special.
Why does "module 'scipy' has no attribute 'interp'" (or 'array', 'zeros') appear?
Until 1.11 the scipy namespace re-exported NumPy's functions. SciPy 1.12.0 (2024-01-20) removed 539 of them. Call them on numpy: np.interp, np.array.
Sources
- The SciPy wheels on PyPI, installed and run, and their source as installed; the release dates are PyPI's.
- scipy/scipy at the tags: scipy/misc/pilutil.py at v1.2.0, scipy/misc/__init__.py at v1.3.0.
The same data as JSON: scipy_names.json, licensed CC BY 4.0.
Related: "module 'numpy' has no attribute 'float_'" · "'DataFrame' object has no attribute 'append'" · "No module named 'torchvision.transforms.functional_tensor'".