报错如下: python用的Anaconda的环境出现了bug

Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
  File "D:\Anaconda\lib\site.py", line 439, in register_readline
    readline.read_history_file(history)
  File "D:\Anaconda\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
    self.mode._history.read_history_file(filename)
  File "D:\Anaconda\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file
    for line in open(filename, 'r'):
UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 1169: illegal multibyte sequence 

 

解决办法:将Anaconda目录里的文件出现了bug少个encoding='utf-8'加一下即可解决

如果找不到Anaconda的路径可以cmd框输入:conda info --envs 查找

目录在:Anaconda\Lib\site-packages\pyreadline\lineeditor的history.py文件的第82行,修改如下:

for line in open(filename, 'r'):添加:变为如下代码,注意不要破坏缩进
    for line in open(filename, 'r',encoding='utf-8'):

效果图:

                                                             

end