onepiece onepiece - 4 months ago 184x
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 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