python-inverse-of-a-matrix failure to import

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.

Answers


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.


SOLVED 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. OldAl.


Need Your Help

Stop a funtion from running with ClearTimeout()

javascript html

I have two buttons to start and stop the progress bar. Here is the code:

C#: Upload Photo To Twitter From Unity

c# twitter unity3d upload media

currently I am working with unity. In this project, I need to post some status with image to twitter. However, I got a problem to upload the image to the Twitter.