apt-get upgrade does not work after updating python [duplicate]

Solution 1:

This is expected. APT (and many other components of Ubuntu) requires a certain version of python to function properly.

To fix the issue, rollback the default python version with

sudo update-alternatives --config python3

To use python 3.10, simply use the command python3.10 (but do not link it against python3, which should be python3.8 in your case).

Alternatively, use virtual python environments.

Never change the default python version, as the system may be messed up so badly that in extreme cases, you will have to reinstall Ubuntu. This site is filled with tears of users who deleted/changed the default python version.

Note: You can use the Deadsnakes PPA to safely install multiple versions of python in LTS versions of Ubuntu.