启动 Python 时产生 Failed calling sys
2020-03-21 本文已影响0人
寂风如雪
今天启动 Python 出现这样的错误
Failed calling sys.__interactivehook__
Traceback (most recent call last):
File "D:\Anaconda3\lib\site.py", line 439, 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 0xa0 in position 469: illegal multibyte sequence
网上搜索了一下,得到解决方案。
该方案由 CSDN 用户 starxhong 在 https://blog.csdn.net/qq595662096/article/details/90170565
的评论中给出,相对不是太好找,搬运一下:
pythonhistory文件,在c:\user\username\下,这个文件中包含了中文。可以直接把报错的history.py文件82行改一下,加一个encoding='utf-8'