在Anaconda Prompt中运行Python时出现UnicodeDecodeError

时间:2019-05-13 04:50:28

标签: python anaconda

当我在Anaconda Prompt中运行python时,出现以下错误。 它不会以任何可见的方式破坏我的Python体验,但是无论如何仍然令我不安。

为什么会这样?

我正在将Anaconda的2019/03版本与Python 3.7.3一起使用

(base) C:\Users>python
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
  File "C:\Users\Anaconda3\lib\site.py", line 439, in register_readline
    readline.read_history_file(history)
  File "C:\Users\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
    self.mode._history.read_history_file(filename)
  File "C:\Users\Anaconda3\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file
    for line in open(filename, 'r'):
  File "C:\Users\Anaconda3\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 2990: character maps to <undefined>

1 个答案:

答案 0 :(得分:1)

del %userprofile%\.python_history 删除了无法为我显示的字符的 Python 历史文件并解决了问题。