Question

Help me to understand what is a problem of this code. As you see it is only two lines of code.

from flask import Flask

app = Flask(__name__)

That return the TypeError.

C:\Users\Natali\AppData\Local\Enthought\Canopy32\User\lib\site-packages\flask\app.pyc in auto_find_instance_path(self)
    620         .. versionadded:: 0.8
    621         """
--> 622         prefix, package_path = find_package(self.import_name)
    623         if prefix is None:
    624             return os.path.join(package_path, 'instance')

C:\Users\Natali\AppData\Local\Enthought\Canopy32\User\lib\site-packages\flask\helpers.pyc in find_package(import_name)
    659     """
    660     root_mod_name = import_name.split('.')[0]
--> 661     loader = pkgutil.get_loader(root_mod_name)
    662     if loader is None or import_name == '__main__':
    663         # import name is not found, or interactive/main module

C:\Program Files\Enthought\Canopy32\App\appdata\canopy-1.3.0.1715.win-x86\lib\pkgutil.pyc in get_loader(module_or_name)
    462     else:
    463         fullname = module_or_name
--> 464     return find_loader(fullname)
    465 
    466 def find_loader(fullname):

C:\Program Files\Enthought\Canopy32\App\appdata\canopy-1.3.0.1715.win-x86\lib\pkgutil.pyc in find_loader(fullname)
    473     """
    474     for importer in iter_importers(fullname):
--> 475         loader = importer.find_module(fullname)
    476         if loader is not None:
    477             return loader

TypeError: find_module() takes exactly 3 arguments (2 given)

Sorry for a long error code. Any idea why it happens?

Was it helpful?

Solution

You need to save the code in a file first, and then run it from the command line. Just typing it in the interactive prompt will not work.

Here is what a minimal Flask application looks like:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
   return 'Hello World'

if __name__ == '__main__':
    app.run()

Save this code to a file (for example, server.py) and then run it with python server.py.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top