django 1.11 with celery 4.0 and djcelery compatibility issues - django

I currently use django 1.11 and I'm forced to use an older version of celery (3.1) for compatibility reasons.
I want to upgrade to celery 4.0 because another part of our application needs the later version of celery.
Is there a combination of celery, django-celery and django 1.11 that is compatible? The docs say that celery 4.0 is compatible with all versions of django from 1.8 onwards, but this does not seem to be the case.
Errors occur for example when I use:
python manage.py makemigrations <appname>
Here is the error message I get:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 337, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/djcelery/models.py", line 16, in <module>
from . import managers
File "/usr/local/lib/python2.7/dist-packages/djcelery/managers.py", line 18, in <module>
from celery.utils.timeutils import maybe_timedelta
ImportError: No module named timeutils
If I revert back to celery 3.1, it works.

... File "/usr/local/lib/python2.7/dist-packages/djcelery/managers.py", line 18, in ...
You are using django-celery, a library which is no longer required since celery 3.1
Previous versions of Celery required a separate library to work with
Django, but since 3.1 this is no longer the case. Django is supported
out of the box now ...
Remove djcelery from INSTALLED_APPS, follow the linked document to see if anything else needs an update and it should work.

Related

celery: ImportError: No module named time

Trying to start celery. I get an error.
Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 327, in execute
django.setup()
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django_celery_beat/models.py", line 19, in <module>
from .clockedschedule import clocked
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django_celery_beat/clockedschedule.py", line 6, in <module>
from celery.utils.time import maybe_make_aware
ImportError: No module named time
I'm use
celery == 3.1.25
django-celery == 3.1.17
django-celery-beat == 1.5.0
Celery versions> 4.0 cannot be used.
According to the changelog, django-celery-beat 1.0.1+ requires Celery 4.0.
You could try django-celery-beat 1.0.0, but if that doesn't work, then you might not be able to use django-celery-beat until you can upgrade to Celery 4.0.

Geonode Installation Oracle Linux

I am running python 2.7.5 and installing geonode in a Oracle Linux machine. I am following the installation manual and I execute the command:
python manage.py migrate
I got the following error
Traceback (most recent call last):
File "manage.py", line 29, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 328, in execute
django.setup()
File "/usr/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/usr/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/opt/apps/geonode/geonode/geonode/base/models.py", line 56, in <module>
from geonode.utils import bbox_to_wkt
File "/opt/apps/geonode/geonode/geonode/utils.py", line 31, in <module>
from slugify import Slugify
File "/usr/lib/python2.7/site-packages/slugify/__init__.py", line 1, in <module>
from slugify.main import Slugify, UniqueSlugify
ImportError: No module named main
Any tip on how to solve this issue?
Thank you for your time in advance
This issue is solved in awesome-slugify 1.6.5 just change its version in geonode/requirements.txt.
N.B: geonode 2.8 is released and the link you follow is not up to date, follow this to get geonode 2.8

Django allauth and ImportError

I've just done this introductions, and when I'm trying
./manage.py migrate
I get this error:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/me0o/work/v_venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/me0o/work/v_venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 327, in execute
django.setup()
File "/home/me0o/work/v_venv/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/me0o/work/v_venv/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/me0o/work/v_venv/local/lib/python2.7/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/me0o/work/v_venv/local/lib/python2.7/site-packages/allauth/socialaccount/providers/__init__.py", line 2, in <module>
from django.utils import importlib
ImportError: cannot import name importlib
I have Django 1.9.2
I have latest version of importlib
Any ideas?
django.utils.importlib was deprecated in Django 1.7 and removed in Django 1.9.
Since the error is occurring in allauth, you should upgrade django-allauth to the latest version. According to the changelog, version 0.24.0 should support Django 1.9.
change your
from django.utils import importlib
to:
from importlib import import_module

django inplaceedit testing project

New to django… Since a month i'm trying to follow this tutorial without success. When i syncdb i get following error:
(virt-inplaceedit)Mac:testing manuelstrasser$ python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/apps/config.py", line 123, in create
import_module(entry)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/sorl/thumbnail/__init__.py", line 1, in <module>
from sorl.thumbnail.fields import ImageField
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/sorl/thumbnail/fields.py", line 6, in <module>
from sorl.thumbnail import default
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/sorl/thumbnail/default.py", line 3, in <module>
from sorl.thumbnail.helpers import get_module_class
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/sorl/thumbnail/helpers.py", line 5, in <module>
from django.utils import simplejson
ImportError: cannot import name simplejson
I installed simplejson but still same error. Anyone haveing experiences with this tutorial? I did everything exactly as per description…
django.utils.simplejson is deprecated in django 1.7.
Looks like you use old version of the sorl-thumbnail. Current version of sorl-thumbnail supports django 1.7 so try to update this library.

django 1.3 server error

I am using django version 1.3. Python manage.py runserver 0.0.0.0:8000 gives the following error.
Validating models...
Unhandled exception in thread started by < bound method Command.inner_run of < django.contrib.staticfiles.management.commands.runserver.Command object at 0x20eb110>>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 88, in inner_run
self.validate(display_num_errors=True)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 36, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 146, in get_app_errors
self._populate()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 64, in _populate
self.load_app(app_name)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 78, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/tastypie/models.py", line 6, in <module>
from tastypie.utils import now
File "/usr/local/lib/python2.7/dist-packages/tastypie/utils/__init__.py", line 1, in <module>
from tastypie.utils.dict import dict_strip_unicode_keys
File "/usr/local/lib/python2.7/dist-packages/tastypie/utils/dict.py", line 1, in <module>
from django.utils.encoding import smart_bytes
ImportError: cannot import name smart_bytes
Its working fine with django 1.4.2+, I was using django1.4 then upgraded it
pip install django==1.4.5 --upgrade
Django 1.3 had the issues of smart_bytes, and from your traceback it shows the same error, its been resolved in Django 1.4, Try upgrading Django to the latest version of 1.5.
See https://github.com/django/django/blob/master/django/utils/encoding.py#L149
Also, always check the release notes before upgrading your Django.
Update:
Sorry about that, wow, what a brainfart ;).
I don't know the full history of that function, but looking at django.utils.encoding on Github.. tagged 1.3.7; this file does not contain the function that Tastypie is attempting to import. https://github.com/django/django/blob/1.3.7/django/utils/encoding.py
If you cannot upgrade Django, you'll need to patch your Tastypie.utils.dict file to work with what you have.