当我尝试运行以下python manage.py celeryd —log-level=info
时,我得到的错误
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
在网上阅读文章并没有真正帮助,因为它们对我来说太详细了解。有人可以建议我如何克服这个错误。
我使用的是Python 2.7.2版本
编辑:错误和区域设置的完整回溯。
(myenv)admin-iMac:example admin$ python manage.py celeryd —log-level=info
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/admin/myenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
utility.execute()
File "/Users/admin/myenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/admin/myenv/lib/python2.7/site-packages/djcelery/management/base.py", line 76, in run_from_argv
self.handle_default_options(argv[2:])
File "/Users/admin/myenv/lib/python2.7/site-packages/djcelery/management/base.py", line 86, in handle_default_options
if '--settings=' in arg:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
来自上述错误的base.py的第86行,是指以下方法中的'if'语句。
def handle_default_options(self, argv):
acc = []
broker = None
for i, arg in enumerate(argv):
# --settings and --pythonpath are also handled
# by BaseCommand.handle_default_options, but that is
# called with the resulting options parsed by optparse.
if '--settings=' in arg:
_, settings_module = arg.split('=')
os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
elif '--pythonpath=' in arg:
_, pythonpath = arg.split('=')
sys.path.insert(0, pythonpath)
elif '--broker=' in arg:
_, broker = arg.split('=')
elif arg == '-b':
broker = argv[i + 1]
else:
acc.append(arg)
if broker:
self.set_broker(broker)
return argv if self.keep_base_opts else acc
以下是区域设置:
(myenv)admin-iMac:example admin$ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"