typeerror: 'module' object is not callable

This error statement TypeError: 'module' object is not callable is raised as you are being confused about the Class name and Module name. The problem is in the import line . You are importing a module, not a class. This happend because the module name and class name have the same name . If you have a class MyClass in a file called MyClass.py , then you should write:
from MyClass import MyClass

How to fix typeerror: 'module' object is not callable

Python type error The following Python example shows, you have a Class named MyClass in a file MyClass.py . If you import the module "MyClass" in another python file sample.py , python sees only the module "MyClass" and not the class name "MyClass" declared within that module. MyClass.py
class MyClass: myVar = 10
sample.py
import MyClass obj = MyClass(); print(obj.myVar);
When you run the sample.py , you will get the following error.
D:\python\dev>python sample.py
Traceback (most recent call last): File "sample.py", line 4, in <module> obj = MyClass(); TypeError: 'module' object is not callable
In Python , a script is a module, whose name is determined by the filename . So when you start out your file MyClass.py with import MyClass you are creating a loop in the module structure.

'module' object is not callable

You can fix this error by change the import statement in the sample.py sample.py
from MyClass import MyClass obj = MyClass(); print(obj.myVar);
Here you can see, when you changed the import statement to from MyClass import MyClass , you will get the error fixed. How to solve typeerror: 'module' object is not callable In Python, everything (including functions, methods, modules, classes etc.) is an object , and methods are just attributes like every others. So,there's no separate namespaces for methods. So when you set an instance attribute, it shadows the class attribute by the same name. The obvious solution is to give attributes different names .