ModuleNotFoundError - poetry / cookiecutter

384 views Asked by At

I'm trying to run commands through poetry and keep getting this error:

Traceback (most recent call last):
  File "manage.py", line 30, in <module>
    execute_from_command_line(sys.argv)
  File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 377, in execute
    django.setup()
  File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/django/apps/config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/pollsapi_w_template/users/models.py", line 11, in <module>
    from pollsapi_w_template.users.emails import RestorePasswordEmail, VerificationEmail
  File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/pollsapi_w_template/users/emails.py", line 3, in <module>
    from snitch.emails import TemplateEmailMessage
  File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/snitch/emails.py", line 11, in <module>
    from snitch.tasks import send_email_asynchronously
  File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/snitch/tasks.py", line 3, in <module>
    from celery.task import task
ModuleNotFoundError: No module named 'celery.task'

I'm in the virtual environment created through poetry.toml and I'm trying to run poetry run python manage.py migrate for example.

I have tried poetry add celery with the following result:

RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
  "program uses threads.", RuntimeWarning)

Python 2.7 will no longer be supported in the next feature release of Poetry (1.2).You should consider updating your Python version to a supported one.

Note that you will still be able to manage Python 2.7 projects by using the env command.
See https://python-poetry.org/docs/managing-environments/ for more information.

Updating dependencies
Resolving dependencies... (1.9s)

Writing lock file

No dependencies to install or update
1

There are 1 answers

0
Suki On

I worked it out, it was a version error: It seems celery 5.0 doesn't have the task module.

I solved it by running poetry add [email protected] .