vps交流

修复 Python 3.10 在 Windows 11 使用 pyreadline 错误


修复 Python 3.10 在 Windows 11 使用 pyreadline 错误
https://github.com/hongwenjun/pyreadline
新电脑安装了 Python 3.10 ,使用 pyreadline 库有问题,google搜索,从两个github项目里找到2个文件的修改方法

  1. Python 3.10.5 (tags/v3.10.5:f377153, Jun  6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
  2. Type "help", "copyright", "credits" or "license" for more information.
  3. Failed calling sys.__interactivehook__
  4. Traceback (most recent call last):
  5.   File "C:UsersvipAppDataLocalProgramsPythonPython310libsite.py", line 446, in register_readline
  6.     import readline
  7.   File "C:UsersvipAppDataLocalProgramsPythonPython310libsite-packagesreadline.py", line 34, in <module>
  8.     rl = Readline()
  9.   File "C:UsersvipAppDataLocalProgramsPythonPython310libsite-packagespyreadlinerlmain.py", line 422, in __init__
  10.     BaseReadline.__init__(self)
  11.   File "C:UsersvipAppDataLocalProgramsPythonPython310libsite-packagespyreadlinerlmain.py", line 62, in __init__
  12.     mode.init_editing_mode(None)
  13.   File "C:UsersvipAppDataLocalProgramsPythonPython310libsite-packagespyreadlinemodesemacs.py", line 633, in init_editing_mode
  14.     self._bind_key(‘space’,       self.self_insert)
  15.   File "C:UsersvipAppDataLocalProgramsPythonPython310libsite-packagespyreadlinemodesbasemode.py", line 162, in _bind_key
  16.     if not callable(func):
  17.   File "C:UsersvipAppDataLocalProgramsPythonPython310libsite-packagespyreadlinepy3k_compat.py", line 8, in callable
  18.     return isinstance(x, collections.Callable)
  19. AttributeError: module ‘collections’ has no attribute ‘Callable’

复制代码

修改替换两个文件
modified:   pyreadline/lineeditor/history.py
modified:   pyreadline/py3k_compat.py