TypeError: 'module' object is not callable

David Robinow drobinow at gmail.com
Fri Aug 12 02:15:39 CEST 2011


On Thu, Aug 11, 2011 at 6:43 PM, Forafo San <ppv.grps at gmail.com> wrote:
> I wrote a class, Univariate, that resides in a directory that is in my PYTHONPATH. I'm able to >import that class into a *.py file. However when I try to instantiate an object with that class like:

  What makes you think you're able to import that class?

> x = Univariate(a)             # a is a list that is expected by the Univariate class
>
> python raises the TypeError: 'module' object is not callable.  If I embed the code of the Univariate >class in my *.py file, there is no problem.  Also, when the class is imported and I do a
>
> print dir(Univariate)
>
> it does not print all the methods that are in the class, while if the class code appears in my *.py >file, all the methods are available and a list with the correct methods are printed.

It appears that you are importing the "module" Univariate from the
file Univariate.py
If you want to instantiate the "class" Univariate contained in the
"module" Univariate, try

 x = Univariate.Univariate(a)

In the future, please try to include more of your code.



More information about the Python-list mailing list