Python 3.7.7 (default, May 6 2020, 11:45:54) [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 "D:\anaconda\envs\py3\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 0xae in position 1637: illegal multibyte sequence
>>>
原因是在读取filename的时候,是以unicode来读取的,需要打开anaconda安装路径下的Anaconda3\lib\site-packages\pyreadline\lineeditor\history.py这个文件,我的是D:\anaconda\Lib\site-packages\pyreadline\lineeditor,修改读取方式
图.PNG
保存重启python即可
(py3) C:\Users\aaa>python
Python 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
网友评论