Win10系统,导入了celery和eventlet模块。我尝试将 celery 添加到我的 django 项目中,在设置文件夹中写入 init 文件并创建 celery.py 文件。我在项目设置中指定了所有必要的变量。运行项目后出现以下错误:
File "E:\PycharmProjects\DRF_homeworks\config\__init__.py", line 1, in <module>
from .celery import app as celery_app
File "E:\PycharmProjects\DRF_homeworks\config\celery.py", line 1, in <module>
from celery import Celery
File "E:\PycharmProjects\DRF_homeworks\venv\Lib\site-packages\celery\local.py", line 460, in __getattr__
module = __import__(self._object_origins[name], None, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\PycharmProjects\DRF_homeworks\venv\Lib\site-packages\celery\app\__init__.py", line 2, in <module>
from config.celery import _state
ImportError: cannot import name '_state' from partially initialized module 'config.celery' (most likely due to a circular import) (E:\PycharmProjects\DRF_homeworks\config\celery.py)
我尝试重命名:
在导入中指定文件的确切路径。
显然出了什么问题。重新安装 celery 包有帮助。问题已结束。