PyCharm调试器中的UnicodeDecodeError

时间:2013-09-16 12:36:51

标签: python encoding utf-8 pycharm cp1251

它是对UnicodeDecodeError while using cyryllic的引用。  我对Python 3.3和Pycharm 2.7.2也有同样的问题 尝试在代码中硬编码编码,在Pycharm选项中手动指定编码,但没有效果。它仍然试图用cp1251 lib打开utf-8文件。

Connected to pydev debugger (build 129.314)
Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 2.7.2\helpers\pydev\pydevd.py", line 1481, in <module>
    debugger.run(setup['file'], None, None)
  File "C:\Program Files (x86)\JetBrains\PyCharm 2.7.2\helpers\pydev\pydevd.py", line 1124, in run
    pydev_imports.execfile(file, globals, locals) #execute the script
  File "C:\Program Files (x86)\JetBrains\PyCharm 2.7.2\helpers\pydev\_pydev_execfile.py", line 33, in execfile
contents = stream.read()
  File "C:\Python33\lib\encodings\cp1251.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 2839: character maps to <undefined>

在调试跟踪器http://youtrack.jetbrains.com/issue/PY-3669中,此问题标记为已解决,但仍处于此处。

有什么建议吗?

1 个答案:

答案 0 :(得分:5)

使用Python 3.3和PyCharm 2.7.3,来自该票证的示例代码对我来说很好(2行:

 # -*- coding: utf-8 -*-
 print("януари")

)。

它对你有用吗?

您使用远程调试器吗?

还有一个可能相关的开放式错误:http://youtrack.jetbrains.com/issue/PY-10241