ImportError: cannot import name 'Callable' from 'collections'

When I runserver , I got this error

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\XXXXXX\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "C:\Users\XXXXXX\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\XXXXXX\Desktop\myenv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\XXXXXX\Desktop\myenv\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
    autoreload.raise_last_exception()
  File "C:\Users\XXXXXX\Desktop\myenv\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "C:\Users\XXXXXX\Desktop\myenv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
    autoreload.check_errors(django.setup)()
  File "C:\Users\XXXXXX\Desktop\myenv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\XXXXXX\Desktop\myenv\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\XXXXXX\Desktop\myenv\lib\site-packages\django\apps\registry.py", line 114, in populate
    app_config.import_models()
  File "C:\Users\XXXXXX\Desktop\myenv\lib\site-packages\django\apps\config.py", line 301, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\XXXXXX\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\XXXXXX\Desktop\spine\qualityManagement\models.py", line 2762, in <module>
    from audiofield.fields import AudioField
  File "C:\Users\XXXXXX\Desktop\myenv\lib\site-packages\audiofield\fields.py", line 20, in <module>
    from celery.utils.log import get_task_logger
  File "C:\Users\XXXXXX\Desktop\myenv\lib\site-packages\celery\utils\__init__.py", line 10, in <module>
    from .nodenames import worker_direct, nodename, nodesplit
  File "C:\Users\XXXXXX\Desktop\myenv\lib\site-packages\celery\utils\nodenames.py", line 9, in <module>
    from .text import simple_format
  File "C:\Users\XXXXXX\Desktop\myenv\lib\site-packages\celery\utils\text.py", line 5, in <module>
    from collections import Callable
ImportError: cannot import name 'Callable' from 'collections' (C:\Users\XXXXXX\AppData\Local\Programs\Python\Python310\lib\collections\__init__.py)

What versions of Python, Django, AudioField, and Celery are you using?
From what I can quickly see, AudioField hasn’t been updated in 3 years and may not be compatible with current Django.

What can I use instead of AudioField?

Python==3.10.1
Django==3.2.9
django-celery==3.1.17
django-audiofield==0.10.0

You can:

  • Fork AudioField and bring it up-to-date yourself.
  • Use it as inspiration and ideas for your own implementation.
  • Try to contact the original author of the package to see if they have any interest in bringing it up to date.
  • Look for another package.
1 Like

See the Notes at the top of First steps with Django — Celery 5.2.1 documentation. You no longer need django-celery. What version of Celery are you using?