Skip to content

python.exe on Windows 10 with Python 3.10 errors after this module is installed #73

Open
DJStompZone/pyreadline
#1

Description

@keeely

After installing, the python executable errors when run interactively. When I uninstalled pyreadline it stopped.

Activity

  1. keeely commented on Nov 18, 2021

    @keeely
    Author

    image

  2. keeely commented on Nov 22, 2021

    @keeely
    Author
  3. liyiliuxingyu commented on Dec 1, 2021

    @liyiliuxingyu

    Please see this link hylang/hy#2114 (comment).

  4. liyiliuxingyu commented on Dec 1, 2021

    @liyiliuxingyu

    Please change the code in line 8 of "c:\python\lib\site-packages\pyreadline\py3k_compat.py" to return isinstance(x, collections.abc.Callable), so that it can run successfully.

  5. liyiliuxingyu commented on Dec 1, 2021

    @liyiliuxingyu

    Hopefully, the developer will fix the bug

  6. duanqn commented on Dec 4, 2021

    @duanqn

    Also hit this issue. Would be nice if someone can fix it.

  7. keeely commented on Dec 14, 2021

    @keeely
    Author

    Please change the code in line 8 of "c:\python\lib\site-packages\pyreadline\py3k_compat.py" to return isinstance(x, collections.abc.Callable), so that it can run successfully.

    Can you create a PR? I deleted the Windows VM I tested this on as I gave up supporting Windows because of this, so I can't easily test such a change. Did you test that on older versions of Python that pyreadline is supposed to support?

  8. eabase commented on Dec 28, 2021

    @eabase

    @liyiliuxingyu
    Changing the code as suggested doesn't completely fix it.
    It just removes one of the errors, and breaks other things.

  9. eabase commented on Dec 28, 2021

    @eabase

    In powershell:

    Before edit:

     $ python
    Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [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:\Python310\lib\site.py", line 446, in register_readline
        import readline
      File "C:\Python310\lib\site-packages\readline.py", line 34, in <module>
        rl = Readline()
      File "C:\Python310\lib\site-packages\pyreadline\rlmain.py", line 422, in __init__
        BaseReadline.__init__(self)
      File "C:\Python310\lib\site-packages\pyreadline\rlmain.py", line 62, in __init__
        mode.init_editing_mode(None)
      File "C:\Python310\lib\site-packages\pyreadline\modes\emacs.py", line 633, in init_editing_mode
        self._bind_key('space',       self.self_insert)
      File "C:\Python310\lib\site-packages\pyreadline\modes\basemode.py", line 162, in _bind_key
        if not callable(func):
      File "C:\Python310\lib\site-packages\pyreadline\py3k_compat.py", line 8, in callable
        return isinstance(x, collections.Callable)
    AttributeError: module 'collections' has no attribute 'Callable'

    after suggested edit in cd C:\Python310\Lib\site-packages\pyreadline\:

     $ python
    Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> if (1):
    ... <I hit a TAB here>
    
    Readline internal error
    Traceback (most recent call last):
      File "C:\Python310\lib\site-packages\pyreadline\console\console.py", line 768, in hook_wrapper_23
        res = ensure_str(readline_hook(prompt))
      File "C:\Python310\lib\site-packages\pyreadline\rlmain.py", line 571, in readline
        self._readline_from_keyboard()
      File "C:\Python310\lib\site-packages\pyreadline\rlmain.py", line 536, in _readline_from_keyboard
        if self._readline_from_keyboard_poll():
      File "C:\Python310\lib\site-packages\pyreadline\rlmain.py", line 556, in _readline_from_keyboard_poll
        result = self.mode.process_keyevent(event.keyinfo)
      File "C:\Python310\lib\site-packages\pyreadline\modes\emacs.py", line 243, in process_keyevent
        r = self.process_keyevent_queue[-1](keyinfo)
      File "C:\Python310\lib\site-packages\pyreadline\modes\emacs.py", line 286, in _process_keyevent
        r = dispatch_func(keyinfo)
      File "C:\Python310\lib\site-packages\pyreadline\modes\basemode.py", line 257, in complete
        completions = self._get_completions()
      File "C:\Python310\lib\site-packages\pyreadline\modes\basemode.py", line 200, in _get_completions
        r = self.completer(ensure_unicode(text), i)
      File "C:\Python310\lib\rlcompleter.py", line 81, in complete
        readline.redisplay()
    AttributeError: module 'readline' has no attribute 'redisplay'
      File "<stdin>", line 2
    
        ^
    IndentationError: expected an indented block after 'if' statement on line 1
  10. eabase commented on Dec 28, 2021

    @eabase

    @keeely
    In addition to the fix above, you also need to fix this:

    You need to edit: C:\Python310\Lib\site-packages\pyreadline\modes\basemode.py:
    Adding the code as shown in #64:

    # at line 196
            if (len(text) == 0):
                return
    
    # at line ~272
            self.insert_text('    ')

    Other related issues:
    #70
    #49

    @liyiliuxingyu
    With these 2 sets of changes it now works great!

  11. liyiliuxingyu commented on Jan 3, 2022

    @liyiliuxingyu

    Changing the code as suggested doesn't fix it!
    It just removes one of the errors, and breaks other things.

    @eabase Thanks. That's great.
    
  12. eabase commented on Jan 14, 2022

    @eabase

    Having used this hack for a while, I am still unhappy. Command completion seem to fail, and instead of "just failing", it

    1. places the 4 spaces ' ' and you need to hit backspace 4 times to get back where you were.
    2. duplicates the completion output for some unknown reason.

    image

    Typing this:
    image

    Then hitting TAB once, give me this:
    image

    (Using pwsh.exe 7.2.1 in Windows Terminal.)


    Seem like there is a hack in #71
    #Override completer from rlcompleter to disable automatic ( on callable

  13. Ghoreish commented on Jun 12, 2023

    @Ghoreish

    Dears,

    I suggest you use the following command to solve the problem:

    python -m pip install --upgrade pyreadline3
    or:
    pip install --upgrade pyreadline3
    or:
    python -m pip install pyreadline3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions