NodePing / PUSH_Clients_Wizard

An interactive command line tool for creating NodePing PUSH checks and deploying client code locally and remotely.
https://nodeping.com/push_check.html
MIT License
3 stars 1 forks source link

Import error from PyInquirer due to too old prompt_toolkit or too new Python version (3.11) #1

Closed girlbossceo closed 11 months ago

girlbossceo commented 12 months ago

Hi! I'm trying to use this wizard client on our Arch Linux servers which runs latest Python (3.11) and generally latest dependencies possible, but the tool appears to be dependent on an older Python version or an older library.

After installing PyInquirer and paramiko and running the script, I get this import error:

Traceback (most recent call last):
  File "/usr/local/src/PUSH_Clients_Wizard/app.py", line 7, in <module>
    from modules import _utils, manage_checks
  File "/usr/local/src/PUSH_Clients_Wizard/modules/_utils.py", line 9, in <module>
    from PyInquirer import prompt, Validator, ValidationError
  File "/root/.local/lib/python3.11/site-packages/PyInquirer/__init__.py", line 6, in <module>
    from prompt_toolkit.token import Token
  File "/root/.local/lib/python3.11/site-packages/prompt_toolkit/__init__.py", line 16, in <module>
    from .interface import CommandLineInterface
  File "/root/.local/lib/python3.11/site-packages/prompt_toolkit/interface.py", line 19, in <module>
    from .application import Application, AbortAction
  File "/root/.local/lib/python3.11/site-packages/prompt_toolkit/application.py", line 8, in <module>
    from .key_binding.bindings.basic import load_basic_bindings
  File "/root/.local/lib/python3.11/site-packages/prompt_toolkit/key_binding/bindings/basic.py", line 9, in <module>
    from prompt_toolkit.renderer import HeightIsUnknownError
  File "/root/.local/lib/python3.11/site-packages/prompt_toolkit/renderer.py", line 11, in <module>
    from prompt_toolkit.styles import Style
  File "/root/.local/lib/python3.11/site-packages/prompt_toolkit/styles/__init__.py", line 8, in <module>
    from .from_dict import *
  File "/root/.local/lib/python3.11/site-packages/prompt_toolkit/styles/from_dict.py", line 9, in <module>
    from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.11/collections/__init__.py)

A quick Google search shows people saying that their script simply needs to be updated (I'm guessing prompt_toolkit), or downgrade Python version: https://stackoverflow.com/a/70557518

I figured I could just update prompt_toolkit but this introduces another import issue:

Traceback (most recent call last):
  File "/usr/local/src/PUSH_Clients_Wizard/app.py", line 7, in <module>
    from modules import _utils, manage_checks
  File "/usr/local/src/PUSH_Clients_Wizard/modules/_utils.py", line 9, in <module>
    from PyInquirer import prompt, Validator, ValidationError
  File "/root/.local/lib/python3.11/site-packages/PyInquirer/__init__.py", line 6, in <module>
    from prompt_toolkit.token import Token
ImportError: cannot import name 'Token' from 'prompt_toolkit.token' (/usr/lib/python3.11/site-packages/prompt_toolkit/token.py)

So in short, the tool needs to be updated to support newer Python versions which also includes updating the dependencies.

Python -V for ref:

python -V
Python 3.11.5
NodePing commented 12 months ago

Hello,

It looks like the library PyInquirer is no longer supported and is known to not work with newer versions of Python. We are looking into other options for a replacement.

NodePing commented 11 months ago

This issue is now resolved with the 1.1.0 release. PyInquirer was replaced with InquirerPy to restore functionality in newer Python versions.