【Anaconda】在命令行输入python后显示Failed calling sys.__interactivehook__

问题描述

Python 3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 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:\ProgramData\Anaconda3\lib\site.py", line 439, in register_readline
    readline.read_history_file(history)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
    self.mode._history.read_history_file(filename)
  File "C:\ProgramData\Anaconda3\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 0xb4 in position 287: illegal multibyte sequence

解决办法

修改C:\ProgramData\Anaconda3\Lib\site-packages\pyreadline\lineeditor中的history.py,第82行加上,encoding='utf-8',修改后如下所示:

for line in open(filename, 'r',encoding='utf-8'):

参考:第8楼大神:https://tieba.baidu.com/p/6126998933

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章