Quantcast
Viewing all articles
Browse latest Browse all 4452

Jammy python installation corrupted for just one user: cannot import name 'Mapping' from 'collections'

I keep my Jammy Ubuntu always up to date, with all updates installed almost daily. So everything I have installed is at its latest version.

I have installed two important applications: a Windows VM on libvirt + qemu, and docker (including docker compose).

One day, I noticed that the Virtual Machine Manager won't start anymore from gnome (I pinned it to my application bar). It just closes automatically, and the error it throws is:ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/init.py)

From command-line, the application, however, starts.

But then, I had to run a docker compose command (which had successfully completed the day before), which resulted in this:

docker-compose up -dTraceback (most recent call last):  File "/usr/bin/docker-compose", line 33, in <module>    sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())  File "/usr/bin/docker-compose", line 25, in importlib_load_entry_point    return next(matches).load()  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load    module = import_module(match.group('module'))  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module    return _bootstrap._gcd_import(name[level:], package, level)  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked  File "<frozen importlib._bootstrap_external>", line 883, in exec_module  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 13, in <module>    import docker.errors  File "/home/myUserName/.local/lib/python3.10/site-packages/docker/__init__.py", line 1, in <module>    from .api import APIClient  File "/home/myUserName/.local/lib/python3.10/site-packages/docker/api/__init__.py", line 1, in <module>    from .client import APIClient  File "/home/myUserName/.local/lib/python3.10/site-packages/docker/api/client.py", line 6, in <module>    import requests  File "/home/myUserName/.local/lib/python3.10/site-packages/requests/__init__.py", line 43, in <module>    import urllib3  File "/home/myUserName/.local/lib/python3.10/site-packages/urllib3/__init__.py", line 8, in <module>    from .connectionpool import (  File "/home/myUserName/.local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 29, in <module>    from .connection import (  File "/home/myUserName/.local/lib/python3.10/site-packages/urllib3/connection.py", line 39, in <module>    from .util.ssl_ import (  File "/home/myUserName/.local/lib/python3.10/site-packages/urllib3/util/__init__.py", line 3, in <module>    from .connection import is_connection_dropped  File "/home/myUserName/.local/lib/python3.10/site-packages/urllib3/util/connection.py", line 3, in <module>    from .wait import wait_for_read  File "/home/myUserName/.local/lib/python3.10/site-packages/urllib3/util/wait.py", line 1, in <module>    from .selectors import (  File "/home/myUserName/.local/lib/python3.10/site-packages/urllib3/util/selectors.py", line 14, in <module>    from collections import namedtuple, MappingImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)

I have tried to re-install python, worked with chatGPT to try to resolve the issue, but nothing worked.

One thing I tried, was to run the same command as root. Surprise, as root, the same command works without a problem!

So there must be something related to my user settings that does not allow python to run.

However, there are no python folders in my ~Nothing in my .config related to python, and just a .local/lib/python3.10/site-packages/ out of which I deleted all .pyc files, and a .local/bin/ that has several python files (I didn't delete those).

So, I tried all I could think of, re-installed python, pip, and now, I'm turning to you if you have any ideas, please help

My python version is 3.10.12


Viewing all articles
Browse latest Browse all 4452

Trending Articles