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文章及評論內容