Why am I getting 'module' object is not callable in python 3? Why am I getting 'module' object is not callable in python 3? tkinter tkinter

Why am I getting 'module' object is not callable in python 3?


You have a module named app that contains a class named app. If you just do import app in main.py then app will refer to the module, and app.app will refer to the class. Here are a couple of options:

  • Leave your import statement alone, and use myApp = app.app({"testFKey":[3,2,2]}) inside of main.py
  • Replace import app with from app import app, now app will refer to the class and myApp = app({"testFKey":[3,2,2]}) will work fine


In main.py change second line to:

from app import app

The issue is you have app module and app class within it. But you are importing module, not the class from it:

myApp = app({"testFKey": [3, 2, 2]})

(you can also instead replace "app" inside line above into "app.app")


The problem, as both F.J and Tadeck already explained, is that app is the module app, and app.app is the class app defined in that module.

You can get around that by using from app import app (or, if you must, even from app import *), as in Tadeck's answer, or by explicitly referring to app.app instead of just app, as in F.J's answer.

If you rename the class to App, that won't magically fix anything—you will still have to either from app import App or refer to app.App—but it will make the problem a whole lot more obvious. And make your code less confusing after you've fixed the problem, too.

This is part of the reason that PEP 8 recommends that:

Modules should have short, all-lowercase names.

Almost without exception, class names use the CapWords convention.

That way, there's no way to mix them up.