celery
celery copied to clipboard
No module named 'backports' after python upgrade
We've upgraded the python version from 3.8 to 3.11. After the upgrade, the celery beat is not starting anymore.
When running celery --app app beat --loglevel WARNING the process crashes with the following error message:
ModuleNotFoundError: No module named 'backports'
The same issue is reported/asked at stackoverflow (using python 3.10): https://stackoverflow.com/q/77416290/10992051
Environment & Settings
Celery version: 5.3.6 (emerald-rush)
celery report Output:
software -> celery:5.3.6 (emerald-rush) kombu:5.3.4 py:3.12.1
billiard:4.2.0 py-amqp:5.2.0
platform -> system:Linux arch:64bit, ELF
kernel version:5.4.0-167-generic imp:CPython
loader -> celery.loaders.default.Loader
settings -> transport:amqp results:disabled
deprecated_settings: None
Steps to Reproduce
Required Dependencies
- Minimal Python Version: 3.11.7
- Minimal Celery Version: 5.3.6
- Minimal Kombu Version: 5.3.4
Python Packages
pip freeze Output:
amqp==5.2.0
asgiref==3.7.2
asttokens==2.4.1
attrs==23.1.0
billiard==4.2.0
bleach==6.1.0
bx-py-utils==71
celery==5.3.6
certifi==2023.11.17
charset-normalizer==3.3.2
click==8.1.7
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.3.0
colorhash==2.0.0
colorutils==0.3.0
decorator==5.1.1
deprecation==2.1.0
dict2xml==1.7.3
Django==4.1.13
django-appconf==1.0.6
django-extensions==3.2.3
django-redis==5.4.0
django-reversion==5.0.8
django-tools==0.54.0
djangorestframework==3.14.0
ecdsa==0.18.0
executing==2.0.1
flower==2.0.1
future==0.18.3
humanize==4.9.0
icdiff==2.0.7
idna==3.6
ipython==8.18.1
jedi==0.19.1
kombu==5.3.4
lxml==4.9.3
MarkupSafe==2.1.3
matplotlib-inline==0.1.6
munch==4.0.0
packaging==23.2
parso==0.8.3
pexpect==4.9.0
Pillow==10.1.0
pprintpp==0.4.0
prometheus-client==0.19.0
prompt-toolkit==3.0.41
psycopg2==2.9.9
ptyprocess==0.7.0
pure-eval==0.2.2
pyasn1==0.5.1
pyasn1-modules==0.3.0
Pygments==2.17.2
python-dateutil==2.8.2
python-dotenv==1.0.0
python-jose==3.3.0
pytz==2023.3.post1
redis==5.0.1
reportlab==4.0.7
requests==2.31.0
requests-toolbelt==1.0.0
rsa==4.9
setuptools==69.0.2
six==1.16.0
sorl-thumbnail==12.10.0
sqlparse==0.4.4
stack-data==0.6.3
tornado==6.4
traitlets==5.14.0
typing_extensions==4.8.0
tzdata==2023.3
urllib3==2.1.0
vine==5.1.0
wcwidth==0.2.12
webencodings==0.5.1
Werkzeug==3.0.1
xmltodict==0.13.0
Actual Behavior
Stacktrace copied from stackoverflow, as mine is much more cluttered:
celery beat v5.3.4 (emerald-rush) is starting.
__ - ... __ - _
LocalTime -> 2023-11-03 10:48:13
Configuration ->
. broker -> redis://redis:6379/0
. loader -> celery.loaders.app.AppLoader
. scheduler -> celery.beat.PersistentScheduler
. db -> celerybeat-schedule
. logfile -> [stderr]@%DEBUG
. maxinterval -> 5.00 minutes (300s)
[2023-11-03 10:48:13,939: DEBUG/MainProcess] Setting default socket timeout to 30
[2023-11-03 10:48:13,940: INFO/MainProcess] beat: Starting...
[2023-11-03 10:48:13,945: CRITICAL/MainProcess] beat raised exception <class 'ModuleNotFoundError'>: ModuleNotFoundError("No module named 'backports'")
Traceback (most recent call last):
File "/usr/local/lib/python3.10/shelve.py", line 111, in __getitem__
value = self.cache[key]
KeyError: 'entries'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/celery/apps/beat.py", line 113, in start_scheduler
service.start()
File "/usr/local/lib/python3.10/site-packages/celery/beat.py", line 634, in start
humanize_seconds(self.scheduler.max_interval))
File "/usr/local/lib/python3.10/site-packages/kombu/utils/objects.py", line 31, in __get__
return super().__get__(instance, owner)
File "/usr/local/lib/python3.10/functools.py", line 981, in __get__
val = self.func(instance)
File "/usr/local/lib/python3.10/site-packages/celery/beat.py", line 677, in scheduler
return self.get_scheduler()
File "/usr/local/lib/python3.10/site-packages/celery/beat.py", line 668, in get_scheduler
return symbol_by_name(self.scheduler_cls, aliases=aliases)(
File "/usr/local/lib/python3.10/site-packages/celery/beat.py", line 513, in __init__
super().__init__(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/beat.py", line 264, in __init__
self.setup_schedule()
File "/usr/local/lib/python3.10/site-packages/celery/beat.py", line 541, in setup_schedule
self._create_schedule()
File "/usr/local/lib/python3.10/site-packages/celery/beat.py", line 570, in _create_schedule
self._store['entries']
File "/usr/local/lib/python3.10/shelve.py", line 114, in __getitem__
value = Unpickler(f).load()
ModuleNotFoundError: No module named 'backports'
Removing the existing scheduler DB is solving the issue, but this should not be neccessary after a python version update/upgrade.