修复 Python 3.10 在 Windows 11 使用 pyreadline 错误 https://github.com/hongwenjun/pyreadline 新电脑安装了 Python 3.10 ,使用 pyreadline 库有问题,google搜索,从两个github项目里找到2个文件的修改方法
- Python 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 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:UsersvipAppDataLocalProgramsPythonPython310libsite.py", line 446, in register_readline
- import readline
- File "C:UsersvipAppDataLocalProgramsPythonPython310libsite-packagesreadline.py", line 34, in <module>
- rl = Readline()
- File "C:UsersvipAppDataLocalProgramsPythonPython310libsite-packagespyreadlinerlmain.py", line 422, in __init__
- BaseReadline.__init__(self)
- File "C:UsersvipAppDataLocalProgramsPythonPython310libsite-packagespyreadlinerlmain.py", line 62, in __init__
- mode.init_editing_mode(None)
- File "C:UsersvipAppDataLocalProgramsPythonPython310libsite-packagespyreadlinemodesemacs.py", line 633, in init_editing_mode
- self._bind_key(‘space’, self.self_insert)
- File "C:UsersvipAppDataLocalProgramsPythonPython310libsite-packagespyreadlinemodesbasemode.py", line 162, in _bind_key
- if not callable(func):
- File "C:UsersvipAppDataLocalProgramsPythonPython310libsite-packagespyreadlinepy3k_compat.py", line 8, in callable
- return isinstance(x, collections.Callable)
- AttributeError: module ‘collections’ has no attribute ‘Callable’
复制代码
修改替换两个文件 modified: pyreadline/lineeditor/history.py modified: pyreadline/py3k_compat.py
|