title: Flask AttributeError: module 'app' has no attribute 'run'
body: <p>My Flask project is structured as follows:</p>
  
  <pre><code>my_project
  │
  ├── app
  │   ├── __init__.py
  │   ├── api
  │   ├── static
  │   └── templates
  ├── config.py
  └── run.py
  </code></pre>
  
  <p><strong>app/__init__.py</strong>:</p>
  
  <pre><code>from flask import Flask
  
  app = Flask(__name__)
  
  app.config.from_object('config')
  </code></pre>
  
  <p><strong>run.py</strong></p>
  
  <pre><code>from app import app
  
  app.run(
      host=app.config.get('HOST', '0.0.0.0'),
      port=app.config.get('PORT', 5000)
  )
  </code></pre>
  
  <p>This worked before, but I'm trying to migrate my project from Python 2 to Python 3, and running <code>python run.py</code> no longer works. I get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/rasmi/Projects/my_project/run.py", line 3, in &lt;module&gt;
      app.run(
  AttributeError: module 'app' has no attribute 'run'
  </code></pre>
  
  <p>If I change the import style in <code>run.py</code> to match the one <a href="https://stackoverflow.com/questions/33839796/nested-package-attributeerror-module-app-has-no-attribute">here</a>:</p>
  
  <pre><code>from .app import app
  
  app.run(
      host=app.config.get('HOST', '0.0.0.0'),
      port=app.config.get('PORT', 5000)
  )
  </code></pre>
  
  <p>I get a different error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/rasmi/Projects/my_project/run.py", line 1, in &lt;module&gt;
      from .app import app
  ModuleNotFoundError: No module named '__main__.app'; '__main__' is not a package
  </code></pre>
  
  <p>Wrapping my <code>app.run()</code> call in an <code>if __name__ == '__main__':</code> block yields the same results. What's causing this issue?</p>