windows电脑
输入CMD命令提示符
C:\Users\liuya>python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
File "C:\Python\Python37\lib\site.py", line 439, in register_readline
readline.read_history_file(history)
File "C:\Python\Python37\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
self.mode._history.read_history_file(filename)
File "C:\Python\Python37\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 0x80 in position 247: illegal multibyte sequence
解决方法:
打开:C:\Python\Python37\lib\site-packages\pyreadline\lineeditor目录下history.py文件,这个文件中包含了中文。
把报错的history.py文件82行改一下,加一个encoding='utf-8',最终显示:for line in open(filename, 'r',encoding='utf-8'):
修改后记得保存
2、再次在cmd命令行界面,输入python命令,查看显示结果:
至此问题即解决
方法2:
删除site-packages目录的pyreadline文件夹
提示:readline模块,有自动补全的功能
以上解决方法参考自:https://blog.csdn.net/qq595662096/article/details/90170565文章及评论内容