Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'Mapping' from 'collections' (C:\Python310\lib\collections\__init__.py) #181

Open
dev-SR opened this issue May 14, 2022 · 8 comments

Comments

@dev-SR
Copy link

dev-SR commented May 14, 2022

Traceback (most recent call last):

  File "D:\CSE\Programs\Selenium\run.py", line 8, in <module>
    from PyInquirer import prompt, print_json
  File "C:\Users\soiko\.virtualenvs\Selenium-nB22m_OD\lib\site-packages\PyInquirer\__init__.py", line 6, in <module>
    from prompt_toolkit.token import Token
  File "C:\Users\soiko\.virtualenvs\Selenium-nB22m_OD\lib\site-packages\prompt_toolkit\__init__.py", line 16, in <module>
    from .interface import CommandLineInterface
  File "C:\Users\soiko\.virtualenvs\Selenium-nB22m_OD\lib\site-packages\prompt_toolkit\interface.py", line 19, in <module>
    from .application import Application, AbortAction
  File "C:\Users\soiko\.virtualenvs\Selenium-nB22m_OD\lib\site-packages\prompt_toolkit\application.py", line 8, in <module>
    from .key_binding.bindings.basic import load_basic_bindings
  File "C:\Users\soiko\.virtualenvs\Selenium-nB22m_OD\lib\site-packages\prompt_toolkit\key_binding\bindings\basic.py", line 9, in <module>
    from prompt_toolkit.renderer import HeightIsUnknownError
  File "C:\Users\soiko\.virtualenvs\Selenium-nB22m_OD\lib\site-packages\prompt_toolkit\renderer.py", line 11, in <module>
    from prompt_toolkit.styles import Style
  File "C:\Users\soiko\.virtualenvs\Selenium-nB22m_OD\lib\site-packages\prompt_toolkit\styles\__init__.py", line 8, in <module>
    from .from_dict import *
  File "C:\Users\soiko\.virtualenvs\Selenium-nB22m_OD\lib\site-packages\prompt_toolkit\styles\from_dict.py", line 9, in <module>
    from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (C:\Python310\lib\collections\__init__.py)
@SultanGabriel
Copy link

Getting the same error

Traceback (most recent call last):
File "C:\Users\sulta\Desktop\mon\cli-test2.py", line 2, in
from PyInquirer import prompt, print_json
File "C:\Users\sulta\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInquirer_init_.py", line 6, in
from prompt_toolkit.token import Token
File "C:\Users\sulta\AppData\Local\Programs\Python\Python310\lib\site-packages\prompt_toolkit_init_.py", line 16, in
from .interface import CommandLineInterface
File "C:\Users\sulta\AppData\Local\Programs\Python\Python310\lib\site-packages\prompt_toolkit\interface.py", line 19, in
from .application import Application, AbortAction
File "C:\Users\sulta\AppData\Local\Programs\Python\Python310\lib\site-packages\prompt_toolkit\application.py", line 8, in
from .key_binding.bindings.basic import load_basic_bindings
File "C:\Users\sulta\AppData\Local\Programs\Python\Python310\lib\site-packages\prompt_toolkit\key_binding\bindings\basic.py", line 9, in
from prompt_toolkit.renderer import HeightIsUnknownError
File "C:\Users\sulta\AppData\Local\Programs\Python\Python310\lib\site-packages\prompt_toolkit\renderer.py", line 11, in
from prompt_toolkit.styles import Style
File "C:\Users\sulta\AppData\Local\Programs\Python\Python310\lib\site-packages\prompt_toolkit\styles_init_.py", line 8, in
from .from_dict import *
File "C:\Users\sulta\AppData\Local\Programs\Python\Python310\lib\site-packages\prompt_toolkit\styles\from_dict.py", line 9, in
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (C:\Users\sulta\AppData\Local\Programs\Python\Python310\lib\collections_init_.py)

@Pankti77Dave
Copy link

Getting the same error
Traceback (most recent call last):
File "d:\python-proj\test.py", line 2, in
from PyInquirer import prompt
File "D:\python\lib\site-packages\PyInquirer_init_.py", line 6, in
from prompt_toolkit.token import Token
File "D:\python\lib\site-packages\prompt_toolkit_init_.py", line 16, in
from .interface import CommandLineInterface
File "D:\python\lib\site-packages\prompt_toolkit\interface.py", line 19, in
from .application import Application, AbortAction
File "D:\python\lib\site-packages\prompt_toolkit\application.py", line 8, in
from .key_binding.bindings.basic import load_basic_bindings
File "D:\python\lib\site-packages\prompt_toolkit\key_binding\bindings\basic.py", line 9, in
from prompt_toolkit.renderer import HeightIsUnknownError
File "D:\python\lib\site-packages\prompt_toolkit\renderer.py", line 11, in
from prompt_toolkit.styles import Style
File "D:\python\lib\site-packages\prompt_toolkit\styles_init_.py", line 8, in
from .from_dict import *
File "D:\python\lib\site-packages\prompt_toolkit\styles\from_dict.py", line 9, in
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (D:\python\lib\collections_init_.py)

@uysalserkan
Copy link

uysalserkan commented Jun 11, 2022

Temp. solution is to downgrade your python version to the correct one.

Edit: Python 3.7 is working well.

@signup-input
Copy link

For Python 3.10.5, change line in file: ...\.venv\Lib\site-packages\prompt_toolkit\styles\from_dict.py
from:
from collections import Mapping to from collections.abc import Mapping.

@minidarkmimi
Copy link

Such modifications are meaningless, and it is impossible to manually modify each node during automated deployment

@S4nd3sh
Copy link

S4nd3sh commented Jul 27, 2023

I completely agree with @minidarkmimi

It is not elegant or feasible in some cases to update site-packages and change the installed code to make it all work.

The latest commit on the Repo works and just needs to be updated on PyPi.
Workaround: Install from Github directly instead of PyPi.

In my case I added this directly in setup.py as a requirement for my own library.

'pyInquirer @ git+https://github.com/CITGuru/PyInquirer.git#7637373429bec66788650cda8091b7a6f12929ee'

@jstafford5380
Copy link

Is there a release for this inbound yet? I just installed recently and still have the issue.

@Volko61
Copy link

Volko61 commented Oct 7, 2024

Also get this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants