title: ImportError: cannot import name celery
body: <p>I'm trying to run some background jobs using Celery + Redis + Flask.</p>
  
  <p>My app structure is:</p>
  
  <pre><code>myapp/
    celery_worker.py
    manage.py
    myapp/
      __init__.py
      app.py
      bot/
        __init__.py
        tasks.py
      accounts/
        views.py
  </code></pre>
  
  <p>I initialise celery into app.py as:</p>
  
  <pre><code>celery = Celery('tasks', include=['bot.tasks'])
  
  def create_app(config=None, app_name=None, blueprints=None):
      # more Celery and other config here like celery.conf.update()
  </code></pre>
  
  <p>And start worker by <code>celery_worker.py</code></p>
  
  <pre><code>from myapp import create_app, celery
  
  app = create_app()
  app.app_context().push()
  </code></pre>
  
  <p><code>tasks.py</code> contains</p>
  
  <pre><code>from myapp import celery
  
  @celery.task(name='my_task_bot')
  def my_task_bot():
       # pass
  </code></pre>
  
  <p>Now, when I try to access tasks from tasks.py into accounts/views.py with following import:</p>
  
  <pre><code>from ..bot.tasks import my_task_bot
  </code></pre>
  
  <p>I getting <code>ImportError: cannot import name celery</code> error.</p>
  
  <p>No matter, where I try to import tasks, I'm getting this error. This <code>celery</code> instance seems to be the one initialised in app.py, but is not getting imported.</p>
  
  <p>PS: I'm following pattern of <a href="https://github.com/ezequielo/flask_celery_exp" rel="nofollow noreferrer">https://github.com/ezequielo/flask_celery_exp</a> repo and it works fine. But not my app.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Here is Traceback:</p>
  
  <pre><code>Traceback (most recent call last):
    File "manage.py", line 8, in &lt;module&gt;
      from myapp import create_app
    File "/home/mars/myapp/myapp/__init__.py", line 3, in &lt;module&gt;
      from app import create_app, celery
    File "/home/mars/myapp/myapp/app.py", line 18, in &lt;module&gt;
      from .accounts import (accounts, AccountsAdmin) 
    File "/home/mars/myapp/myapp/accounts/__init__.py", line 7, in &lt;module&gt;
      from .views import accounts
    File "/home/mars/myapp/myapp/accounts/views.py", line 6, in &lt;module&gt;
      from ..bot.tasks import my_task_bot
    File "/home/mars/myapp/myapp/bot/tasks.py", line 14, in &lt;module&gt;
      from myapp import celery
  ImportError: cannot import name celery
  
  Fatal error: local() encountered an error (return code 1) while executing 'python manage.py initdb'
  </code></pre>
  
  <p>I get above error on trying to start any of either <code>manage.py</code> or <code>celery_worker</code>.</p>
  
  <p>Please suggest.</p>