美文网首页
启动python的错误:UnicodeDecodeError:

启动python的错误:UnicodeDecodeError:

作者: 1037号森林里一段干木头 | 来源:发表于2020-08-04 16:10 被阅读0次
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.
>>>

相关文章

网友评论

      本文标题:启动python的错误:UnicodeDecodeError:

      本文链接:https://www.haomeiwen.com/subject/swmirktx.html