Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name linsolve

Tags:

python

scipy

I am testing a piece of Python code that contains the line:

from scipy import sparse, linsolve

When I run the script, I get the error:

    from scipy import sparse, linsolve
ImportError: cannot import name linsolve

A quick google search shows the code for linsolve.py (hosted on Koders.com). My question is:

Is linsolve a part of scilab - or do I need to download linsolve.py separately?

like image 817
Homunculus Reticulli Avatar asked Feb 18 '12 10:02

Homunculus Reticulli


1 Answers

If the code in question is actually trying to import scipy.linsolve, that was deprecated a long time ago, and may well have been remove from the latest versions of scipy. For compatibility you could try this:

from scipy import sparse
import scipy.sparse.linalg.dsolve as linsolve

that should give the code the sparse and linsolve it relies on and shouldn't require any other modifications (unless there is something inside linsolve it relies on which has also changed, of course).

like image 173
talonmies Avatar answered Sep 28 '22 01:09

talonmies