PyInquirer icon indicating copy to clipboard operation
PyInquirer copied to clipboard

Use latest prompt_toolkit

Open J4NS-R opened this issue 3 years ago • 3 comments

This resolves an import error in the collections library when using python 3.10 or higher.

ImportError: cannot import name 'Mapping' from 'collections' (/opt/homebrew/Cellar/[email protected]/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/__init__.py)

J4NS-R avatar Nov 11 '22 14:11 J4NS-R

Love the 3.10 migration work! Forced the update to prompt_toolkit=3.0.32 on my machine and it introduces an import error. More work would need to resolve that: image

cdelahanty avatar Nov 11 '22 19:11 cdelahanty

I know the PyPi is not up to date and forces users to install older prompt-toolkit.

The workaround for me that worked is to install from the latest commit. It did pull the prompt-toolkit 3.x.xx and didn't raise any errors when loading it. 'pyInquirer @ git+https://github.com/CITGuru/PyInquirer.git#7637373429bec66788650cda8091b7a6f12929ee'

The change I made in the code moving from PyPi install is change the import of prompt from PyInquirer, from PyInquirer import prompt change to from PyInquirer.prompt import prompt

S4nd3sh avatar Jul 27 '23 11:07 S4nd3sh

And what about to do:

try:
    from collections.abc import Mapping
except ImportError:
    from collections import Mapping

to keep that backwards compatible?

kubow avatar Aug 14 '24 16:08 kubow