Q:

Accessing Celery instance outside of Virtualenv

I have a flask based API operating inside of a virtual environment on my server.  I wish for my API to call celery tasks however Celery is installed and already running for other purposes outside of the virtual environment that the API runs in.  How do I import my tasks module in such a way that it can be used inside of the virtualenv.  
Sorry if this is a dumb question using Virtualenv is new to me.

A:

You just have to install the dependencies required to load the 'tasks' module inside the virtualenv too (e.g. pip install celery).
The act of sending the task is not really related to the virtualenv, it only needs to communicate with the right broker URL (this can be a bit more complicated when using e.g. the Django database as a broker though).
In fact you easily send a task by name too:
$ python
>>> from celery import Celery
>>> Celery(broker='amqp://').send_task('tasks.add', (2, 2))

So the broker is the only required communication point, but the tasks.py module and Celery application can contain configuration that affect how tasks are sent (like routing to different queues, setting default queue names and queue + task configuration and so on).

