module 'schedule' has no attribute 'every

python 在使用 schedule定时任务是,报错 "module 'schedule' has no attribute 'every"

解决方案:

是因为我所在的文件路径中,自己有定义schedule.py ,所以解析器会同时读取到该路径下的模块,

把该模块的名字修改掉就可以了!

dkl@dkl-VMware-Virtual-Platform:~/learn/graph/study_celery$ celery -A celery_task worker -I info Usage: celery [OPTIONS] COMMAND [ARGS]... Try 'celery --help' for help. Error: Invalid value for '-A' / '--app': Unable to load celery application. While trying to load the module celery_task the following error occurred: Traceback (most recent call last): File "/home/dkl/learn/env/lib/python3.12/site-packages/celery/app/utils.py", line 389, in find_app found = sym.app ^^^^^^^ AttributeError: module 'celery_task' has no attribute 'app' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/dkl/learn/env/lib/python3.12/site-packages/celery/app/utils.py", line 394, in find_app found = sym.celery ^^^^^^^^^^ AttributeError: module 'celery_task' has no attribute 'celery' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/dkl/learn/env/lib/python3.12/site-packages/celery/app/utils.py", line 383, in find_app sym = symbol_by_name(app, imp=imp) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/dkl/learn/env/lib/python3.12/site-packages/kombu/utils/imports.py", line 64, in symbol_by_name return getattr(module, cls_name) if cls_name else module ^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'celery_task' has no attribute 'celery' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/dkl/learn/env/lib/python3.12/site-packages/celery/bin/celery.py", line 58, in convert return find_app(value) ^^^^^^^^^^^^^^^ File "/home/dkl/learn/env/lib/python3.12/site-packages/celery/app/utils.py", line 401, in find_app return find_app( ^^^^^^^^^ File "/home/dkl/learn/env/lib/python3.12/site-packages/celery/app/utils.py", line 386, in find_app sym = imp(app) ^^^^^^^^ File "/home/dkl/learn/env/lib/python3.12/site-packages/celery/utils/imports.py", line 109, in import_from_cwd return imp(module, package=package) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1387, in _gcd_import File "<frozen importlib._bootstrap>", line 1360, in _find_and_load File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 935, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 995, in exec_module File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed File "/home/dkl/learn/graph/study_celery/celery_task/celery.py", line 30, in <module> 'schedule': crontab(seconds=10), ^^^^^^^^^^^^^^^^^^^ File "/home/dkl/learn/env/lib/python3.12/site-packages/celery/schedules.py", line 409, in __init__ super().__init__(**kwargs) TypeError: BaseSchedule.__init__() got an unexpected keyword argument 'seconds'
最新发布
03-28
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值