错误信息如下:
raceback (most recent call last):
File "/home/xuxiaolong/anaconda3/lib/python3.6/site-packages/celery/app/utils.py", line 228, in find_app
found = sym.app
AttributeError: module 'celeryDemo' has no attribute 'app'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/xuxiaolong/anaconda3/bin/celery", line 11, in
sys.exit(main())
File "/home/xuxiaolong/anaconda3/lib/python3.6/site-packages/celery/__main__.py", line 30, in main
main()
File "/home/xuxiaolong/anaconda3/lib/python3.6/site-packages/celery/bin/celery.py", line 80, in main
cmd.execute_from_commandline(argv)
File "/home/xuxiaolong/anaconda3/lib/python3.6/site-packages/celery/bin/celery.py", line 723, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
File "/home/xuxiaolong/anaconda3/lib/python3.6/site-packages/celery/bin/base.py", line 301, in execute_from_commandline
argv = self.setup_app_from_commandline(argv)
File "/home/xuxiaolong/anaconda3/lib/python3.6/site-packages/celery/bin/base.py", line 431, in setup_app_from_commandline
self.app = self.find_app(app)
File "/home/xuxiaolong/anaconda3/lib/python3.6/site-packages/celery/bin/base.py", line 451, in find_app
return find_app(app, symbol_by_name=self.symbol_by_name)
File "/home/xuxiaolong/anaconda3/lib/python3.6/site-packages/celery/app/utils.py", line 233, in find_app
found = sym.celery
AttributeError: module 'celeryDemo' has no attribute 'celery'
代码目录结构:
celeryDemo
--__init__.py
--tasks.py
--CeleryConf.py
--config.py
config.py代码:
from future import absolute_import
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/5'
BROKER_URL = 'redis://127.0.0.1:6379/6'
celeryconf.py代码:
from future import absolute_import
from celery import Celery
app=Celery('celeryDemo', include=['celeryDemo.tasks'])
app.config_from_object('celeryDemo.config')
if name == '__main__':
app.start()
tasks.py代码:
from future import absolute_import
from celeryDemo.celeryConf import app
#from celeryDemo.scrapyLijia import scrapyProcess
@app.task
def add(x, y):
return x + y
"""
@app.task
def spider(region):
q =[]
process = scrapyProcess(region,q,"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0",None,5)
process.start()
"""
当家帮忙看下,我查了好久不知道啥问题