Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery - No module named five

After updating celery and django-celery to 3.1:

$ pip freeze | grep celery
celery==3.1.18
django-celery==3.1.16

I run into this error when starting my server:

Traceback (most recent call last):
  File "app/manage.py", line 16, in <module>
    execute_from_command_line(sys.argv)
  [...]
  File "/Users/xxx/.virtualenvs/yyy/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/xxx/.virtualenvs/yyy/lib/python2.7/site-packages/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named five

Using:

  • Django 1.4.21
  • Python 2.7
like image 211
laffuste Avatar asked Sep 24 '15 08:09

laffuste


3 Answers

Last version of vine is 5.0.0 and fresh push was in 06.09.2020 (yesterday) :), and this version do not have any five.py file. So downgrade vine version to.

vine==1.3.0

works for me

UPDATE: by the answer Sarang, amqp and celery now requires vine>=5.0.0

like image 59
RandeView Avatar answered Sep 20 '22 06:09

RandeView


Some suggestions found in internet were:

  • Reinstall both (because of a celery and django-celery version mismatch)

  • Upgrade celery

What worked for me was to upgrade kombu:

pip install kombu -U

NOTE: after updating to celery 3.1, django is supported out of the box.

like image 4
laffuste Avatar answered Sep 20 '22 06:09

laffuste


You need to create a celery app according to new celery setup. Create a file celery.py in your project folder with settings.

from __future__ import absolute_import

import os
import sys

from celery import Celery


sfile = 'mysettings_file' # override it
os.environ.setdefault('DJANGO_SETTINGS_MODULE', sfile)


from django.conf import settings

project_name = 'referral' # override it

app = Celery(project_name)
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda : settings.INSTALLED_APPS)

In your app/tasks.py, add your task

from referral import celery_app # substitute your project folder

class MyTask(celery_app.Task):

     pass

Then, use this app to register your tasks. Infact, you don't need djcelery if you want to use celery with django, unless you are using it as database backend.

like image 2
hspandher Avatar answered Sep 22 '22 06:09

hspandher