onepiece onepiece - 1 year ago 1020
Python Question

Flask - ImportError: No module named app

First I created

from flask import Flask

app = Flask(__name__)

Then in a separate file, in the same directory,

from app import app
debug = True

When I try to run
, I get the error

Traceback (most recent call last):
File "", line 1, in <module>
from app import app
ImportError: No module named app

Answer Source is imported using a directory. if you want to import it as app you should put file in directory named app

a better option is just to rename to

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download