【问题标题】:Python terminal gives error after openingPython终端打开后出现错误
【发布时间】:2021-08-16 07:09:07
【问题描述】:

当我试图通过python 命令从终端打开 python 时,我突然遇到了一个错误,终端正常工作,但我想知道为什么会这样,提前谢谢。

PS C:\Users\blackbird> py
AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
  File "C:\Users\blackbird\AppData\Local\Programs\Python\Python38\lib\site.py", line 440, in register_readline
    readline.read_history_file(history)
  File "C:\Users\blackbird\AppData\Local\Programs\Python\Python38\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
    self.mode._history.read_history_file(filename)
  File "C:\Users\blackbird\AppData\Local\Programs\Python\Python38\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file
    for line in open(filename, 'r'):
  File "C:\Users\blackbird\AppData\Local\Programs\Python\Python38\lib\encodings\cp1254.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9e in position 886: character maps to <undefined>
>>>

【问题讨论】:

    标签: python terminal


    【解决方案1】:

    我注意到pyreadline 软件包是从“requirements.txt”文件无意中安装在我的计算机上的。

    来自documentation

    pyreadline 包是 GNU readline 的 python 实现 功能它基于基于 ctypes 的 UNC readline 包 加里毕晓普。它不完整。它已经过测试可用于 Windows 2000 和 Windows XP。
    ...
    pyreadline 的 2.1 版已针对 Python 2.7 和 3.4、3.5 进行了验证。

    删除pyreadline 包解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2021-11-27
      • 2013-05-15
      • 2019-06-27
      • 1970-01-01
      • 2014-04-15
      • 1970-01-01
      • 2017-02-07
      • 2013-10-26
      相关资源
      最近更新 更多