UnicodeDecodeError:'ascii'编解码器无法解码位置0的字节0x96

时间:2014-07-15 23:22:21

标签: python django celery python-unicode

我查看了类似问题的一些答案,但似乎无法看到我的代码中出现错误的位置。当我尝试运行celery时发生错误:celery –A runLogProject worker –loglevel=INFO。我注释掉了与Celery相关的所有代码,它也给出了同样的错误。我也尝试重新安装芹菜。我不知道还有什么可以尝试的。这是追溯:

 C:\Python27\lib\site-packages\celery\bin\celery.py:803: UnicodeWarning: Unicode equal comparison failed to convert both
arguments to Unicode - interpreting them as being unequal
  if len(argv) > 1 and 'worker' in argv[0:3]:
C:\Python27\lib\site-packages\celery\bin\celery.py:765: UnicodeWarning: Unicode equal comparison failed to convert both
arguments to Unicode - interpreting them as being unequal
  if 'multi' in argv[1:3]:  # Issue 1008
C:\Python27\lib\site-packages\celery\bin\base.py:398: UnicodeWarning: Unicode equal comparison failed to convert both ar
guments to Unicode - interpreting them as being unequal
  if '--version' in argv:
Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\celery.exe\__main__.py", line 9, in <module>
  File "C:\Python27\lib\site-packages\celery\__main__.py", line 30, in main
    main()
  File "C:\Python27\lib\site-packages\celery\bin\celery.py", line 81, in main
    cmd.execute_from_commandline(argv)
  File "C:\Python27\lib\site-packages\celery\bin\celery.py", line 769, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "C:\Python27\lib\site-packages\celery\bin\base.py", line 304, in execute_from_commandline
    argv = self.setup_app_from_commandline(argv)
  File "C:\Python27\lib\site-packages\celery\bin\base.py", line 435, in setup_app_from_commandline
    preload_options = self.parse_preload_options(argv)
  File "C:\Python27\lib\site-packages\celery\bin\base.py", line 500, in parse_preload_options
    return self.preparse_options(args, self.preload_options)
  File "C:\Python27\lib\site-packages\celery\bin\base.py", line 512, in preparse_options
    if arg.startswith('--'):
UnicodeDecodeError: 'ascii' codec can't decode byte 0x96 in position 0: ordinal not in range(128)

1 个答案:

答案 0 :(得分:8)

那个棘手的问题。问题在于你输入命令的方式:

错误:

celery –A runLogProject worker –loglevel=INFO

正确:

celery -A runLogProject worker -loglevel=INFO

几乎不可能发现差异。首先传递参数-A和-loglevel使用破折号(ascii代码:8211),但应使用连字符(ascii代码45)。

如果您使用的是OSX,可能会触发它,因为您按下ALT和连字符/减号键,或者您只是从使用奇怪的自动更正的博客中复制粘贴它。