编程语言
首页 > 编程语言> > python – UnicodeDecodeError:’ascii’编解码器无法解码位置0的字节0x96

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

作者:互联网

我查看了类似问题的一些答案,但似乎无法看到我的代码中出现错误的位置.当我尝试运行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)

解决方法:

这是棘手的问题.问题出在你输入命令的方式:

错误:

celery –A runLogProject worker –loglevel=INFO

正确:

celery -A runLogProject worker -loglevel=INFO

发现差异几乎是不可能的.在第一个传递参数-A和-loglevel使用破折号(ascii代码:8211)但应该用连字符(ascii代码45).

如果你正在使用OSX,它可能会被触发,因为你用连字符和减号键一起按下ALT,或者只是从一些使用奇怪的自动更正的博客复制粘贴它.

标签:python-unicode,python,django,celery
来源: https://codeday.me/bug/20190725/1530246.html