tags:

views:

30

answers:

1

I thought that the code in the python-inverse-of-a-matrix was extremely interesting, particularly since I have used numpy for several years in computations that involve matrices. I was disappointed as the 2 imports from numpy failed. Here are the imports:

from numpy import matrix
from numpy import linalg

Neither matrix nor linalg were found in the numpy package. Clearly I miss something that is quite obvious (not for me, though :) ).

I use Linux (kubuntu) and downloaded the numpy package as a debian package. Are there other packages for "matrix" and for "linalg", if so, what are they?

Thank you in anticipation,

OldAl.

+3  A: 

Most likely, you have a numpy.py or numpy.pyc file in your local directory... and python is finding it and importing it instead of the numpy package you expect.

Try this before importing.

import numpy
print(numpy.__file__)

You'll probably find that numpy.__file__ is pointing not to the numpy package, but to something you did not intend to import.

In general, it's a good idea to name your own modules with different names from known/popular packages.

Jason R. Coombs
Actually, numpy is imported and works correctly. Has for the last 5 years... The deb package numpy simply does not have the matrix and linalg sub-packages. In ubuntu or kubuntu one needs to import scipy as well. Scipy expands the name space of numpy and adds matrix and linalg packages and more. Thanks for you contribution!OldAl.
OldAl - since you found your answer, I suggest you answer you own question, then mark it as the correct answer.
Jason R. Coombs