命令行输入python,出现一大串警告内容如下所示:

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 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 0x9a in position 140: illegal multibyte sequence

解决办法:

找到安装路径D:\anaconda3\Lib\site-packages\pyreadline\lineeditor中的history.py文件,第82行

for line in open(filename, 'r'):

改为

for line in open(filename, 'r', encoding='utf-8'):

完美解决!!

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐