-1

I'm having trouble using the least squares solver scipy.sparse.linalg.lsmr, I'm getting the following error:

AttributeError: 'module' object has no attribute 'lsmr'

at the top of my script I have

import scipy.sparse.linalg

I have of coursed tried google, but came up with nothing as the error is quite vague.

Does anybody have an idea on how to solve this?

Thanks!

A.J. Uppal
  • 19,117
  • 6
  • 45
  • 76
user1254962
  • 153
  • 5
  • 15
  • possible duplicate of [AttributeError: 'module' object (scipy) has no attribute 'misc'](http://stackoverflow.com/questions/13581593/attributeerror-module-object-scipy-has-no-attribute-misc) – duffymo Jun 07 '14 at 17:08
  • @duffymo: no, the `import` is correct here. – Fred Foo Jun 07 '14 at 18:58

1 Answers1

0

what version of scipy do you have installed? You should have a lsmr.py in your python libraries. In Slackware 14.1 Mine is located in

$ locate lsmr.py
/usr/lib64/python2.7/site-packages/scipy/sparse/linalg/isolve/lsmr.py
/usr/lib64/python2.7/site-packages/scipy/sparse/linalg/isolve/lsmr.pyc
/usr/lib64/python2.7/site-packages/scipy/sparse/linalg/isolve/tests/test_lsmr.py

If the lsmr algorithm is more sutable to your applcation you may be able to upgrade Scipy, with pip, or find a compatible version of the library at. https://github.com/scipy/scipy/blob/master/scipy/sparse/linalg/isolve/lsmr.py I have also used the anaconda python installer in my home directory with much sucess.

jvish
  • 23
  • 5
  • Well I executed 'locate lsmr.py' and it doesn't return anything.. However, I changed lsmr to lsqr (which seems to do the same), and this one works. I don't have any problems with other scipy functions, so I find it quite odd. Anyway, thanks for the suggestion :) – user1254962 Jun 07 '14 at 18:23