title: "ImportError: cannot import name mail" in Flask
body: <p>I have built is a simple web app with Flask and Python, which I intend to upload to Heroku.</p>
  
  <p>When starting my app locally, with the following script:</p>
  
  <pre><code>#!venv/bin/python
  from app import app
  app.run(debug = True)
  </code></pre>
  
  <p>I get this error message:</p>
  
  <pre><code>Traceback (most recent call last):
  File "./run.py", line 2, in &lt;module&gt;
      from app import app, mail
  File "/home/ricardo/personalSite/app/__init__.py", line 3, in &lt;module&gt;
      from app import index
  File "/home/ricardo/personalSite/app/index.py", line 6, in &lt;module&gt;
      from emails import send_email
  File "/home/ricardo/personalSite/app/emails.py", line 2, in &lt;module&gt;
      from app import app, mail
  ImportError: cannot import name mail
  </code></pre>
  
  <p>So, it cannot import <code>mail</code>.</p>
  
  <p>Inside the <code>app</code> directory I have this <code>__init__.py</code>, here is were I create the <code>Mail</code> object that is ginving me trouble to import:</p>
  
  <pre><code>from flask import Flask
  app = Flask(__name__)
  from app import index
  from flask.ext.mail import Mail
  mail = Mail(app)
  </code></pre>
  
  <p>And this is the file <code>emails.py</code> where I call the <code>send_mail</code> function:</p>
  
  <pre><code>from flask.ext.mail import Message
  from app import app, mail
  from flask import render_template
  from config import ADMINS
  from decorators import async
  </code></pre>
  
  <p>So, according to the error message, the error is in this file, in the <code>from app import app, mail</code>.</p>
  
  <p>What is the problem? Why can't it import <code>mail</code>?</p>
  
  <p>Update:</p>
  
  <p>This is my directory listing:</p>
  
  <pre><code>persSite\
    venv\
      &lt;virtual environment files&gt;
    app\
      static\
      templates\
      __init__.py
      index.py
      emails.py
      decorators.oy
    tmp\
    run.py
  </code></pre>