ImportError: cannot import name 'Mapping' from 'collections'

When I try to install wxPython with pip I get this message:

C:\Users\name>py -m pip install -U wxPython
Collecting wxPython
Using cached wxPython-4.2.0.tar.gz (71.0 MB)
Preparing metadata (setup.py) … error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
Traceback (most recent call last):
File “”, line 2, in
File “”, line 34, in
File “C:\Users\name\AppData\Local\Temp\pip-install-m0kd10hi\wxpython_a0b80c06290645f2aeaebbebd8ac1324\setup.py”, line 27, in
from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
File “C:\Users\name\AppData\Local\Temp\pip-install-m0kd10hi\wxpython_a0b80c06290645f2aeaebbebd8ac1324\buildtools\config.py”, line 30, in
from attrdict import AttrDict
File “C:\Users\name\AppData\Local\Programs\Python\Python311\Lib\site-packages\attrdict_init_.py”, line 5, in
from attrdict.mapping import AttrMap
File “C:\Users\name\AppData\Local\Programs\Python\Python311\Lib\site-packages\attrdict\mapping.py”, line 4, in
from collections import Mapping
ImportError: cannot import name ‘Mapping’ from ‘collections’ (C:\Users\name\AppData\Local\Programs\Python\Python311\Lib\collections_init_.py)
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Having recently had the same problem with wxPython, I solved it by doing a “pip install Mapping” (which, IIRC, prompted similar pip loads before Mapping and then wxPython finally loaded)