执行启动worker命令报错SyntaxError: invalid syntax

问题描述:

启动worker,执行命令 E:\HttpRunnerManager>python manage.py celery -A HttpRunnerManager worker --loglevel=info

报错 SyntaxError: invalid syntax

  File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\celery\concurrency\prefork.py", line 20, in 
    from celery.concurrency.base import BasePool
  File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\celery\concurrency\base.py", line 21, in 
    from celery.utils import timer2
  File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\celery\utils\timer2.py", line 19
    from kombu.async.timer import Entry, Timer as Schedule, to_timestamp, logger
                   ^
SyntaxError: invalid syntax

问题解析:

排除脚本语法问题、路径问题、pip安装目录问题,那就是celery版本的问题了

解决方法:

1、使用pip list 可查看celery版本

2、卸载当前的celery版本,卸载命令:pip uninstall celery

3、安装指定版本4.4.7,安装命令:pip install celery==4.4.7

E:\HttpRunnerManager>pip uninstall celery
Found existing installation: celery 3.1.26.post2
Uninstalling celery-3.1.26.post2:
  Would remove:
    c:\users\administrator\appdata\roaming\python\python37\scripts\celery.exe
    c:\users\administrator\appdata\roaming\python\python37\scripts\celerybeat.exe
    c:\users\administrator\appdata\roaming\python\python37\scripts\celeryd-multi.exe
    c:\users\administrator\appdata\roaming\python\python37\scripts\celeryd.exe
    c:\users\administrator\appdata\roaming\python\python37\site-packages\celery-3.1.26.post2.dist-info\*
    c:\users\administrator\appdata\roaming\python\python37\site-packages\celery\*
Proceed (y/n)? y
  Successfully uninstalled celery-3.1.26.post2

E:\HttpRunnerManager>pip install celery==4.4.7

参考:http://www.chenxm.cc/article/1006.html

你可能感兴趣的:(celery,celery)