我想从官方教程中运行示例代码(tasks.py):
from celery import Celery
app = Celery('tasks', broker='amqp://guest@localhost//')
@app.task
def add(x, y): return x + y
我使用命令"芹菜-A任务工作者-loglevel = info",如教程所示。但是,当我执行此命令时
C:kaznmuvirtualenvsexampleScripts>celery -A tasks worker --loglevel=info
Traceback (most recent call last):
File "C:kaznmuvirtualenvsexampleScriptscelery-script.py", line 9, in <mod
ule>
load_entry_point('celery==3.1.8', 'console_scripts', 'celery')()
File "C:kaznmuvirtualenvsexamplelibsite-packagescelery__main__.py", lin
e 30, in main
main()
File "C:kaznmuvirtualenvsexamplelibsite-packagescelerybincelery.py", l
ine 80, in main
cmd.execute_from_commandline(argv)
File "C:kaznmuvirtualenvsexamplelibsite-packagescelerybincelery.py", l
ine 746, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
File "C:kaznmuvirtualenvsexamplelibsite-packagescelerybinbase.py", lin
e 308, in execute_from_commandline
return self.handle_argv(self.prog_name, argv[1:])
File "C:kaznmuvirtualenvsexamplelibsite-packagescelerybincelery.py", l
ine 738, in handle_argv
return self.execute(command, argv)
File "C:kaznmuvirtualenvsexamplelibsite-packagescelerybincelery.py", l
ine 692, in execute
).run_from_argv(self.prog_name, argv[1:], command=argv[0])
File "C:kaznmuvirtualenvsexamplelibsite-packagescelerybinworker.py", l
ine 175, in run_from_argv
return self(*args, **options)
File "C:kaznmuvirtualenvsexamplelibsite-packagescelerybinbase.py", lin
e 271, in __call__
ret = self.run(*args, **kwargs)
File "C:kaznmuvirtualenvsexamplelibsite-packagescelerybinworker.py", l
ine 195, in run
hostname = self.simple_format(default_nodename(hostname))
File "C:kaznmuvirtualenvsexamplelibsite-packagescelerybinbase.py", lin
e 569, in simple_format
return self._simple_format(s, socket.gethostname(), **extra)
File "C:kaznmuvirtualenvsexamplelibsite-packagescelerybinbase.py", lin
e 574, in _simple_format
name, _, domain = host.partition('.')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcf in position 5: ordinal
not in range(128)
- 我尝试重新安装所有Python库并使用不同的版本,但这无济于事。我该如何运行芹菜?
- 我使用Windows7和Python2.7
- 官方教程在这里http://docs.celeryproject.org/en/master/getting-started/first-steps-with-celery.html#first-steps
问题是PC名称中的俄罗斯字符。通过重命名PC名称来解决。