Windows上 CMD输入python,突然会报错。
Python 3.6.12 |Anaconda 4.2.0 (64-bit)| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
Failed calling sys.interactivehook
Traceback (most recent call last):
File “D:\Anaconda3\lib\site.py”, line 418, in register_readline
readline.read_history_file(history)
File “D:\Anaconda3\lib\site-packages\pyreadline\rlmain.py”, line 165, in read_history_file
self.mode._history.read_history_file(filename)
File “D:\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 0x88 in position 7: illegal multibyte sequence
系统装的pyreadline版本是: v2.1
尝试升级版本,好像也没有成功。
找到Anaconda3\Lib\site-packages\pyreadline\lineeditor\history.py 中82行,
把原来的 open(filename, ‘r’) 改为 open(filename, ‘r’,encoding=‘utf-8’)