I've been trying to upgrade from Ubuntu 20.04 to 22.04. I'm trying to do this by running:
sudo do-release-upgrade
I'm met with the following:
Traceback (most recent call last):
File "/usr/bin/do-release-upgrade", line 11, in <module>
from UpdateManager.Core.MetaRelease import MetaReleaseCore
File "/usr/lib/python3/dist-packages/UpdateManager/Core/MetaRelease.py", line 25, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
I've removed and reinstalled python3-apt like here, but this doesn't do anything. I'm met with a similar error when even removing:
Removing ubuntu-advantage-tools (27.14.4~20.04) ...
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "/usr/lib/python3/dist-packages/uaclient/apt.py", line 14, in <module>
import apt # type: ignore
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
dpkg: error processing package ubuntu-advantage-tools (--remove):
installed ubuntu-advantage-tools package pre-removal script subprocess returned
error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
ubuntu-advantage-tools
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
From what I gather this could also be due to me having the wrong Python version (3.8). Using update-alternatives I've installed 3.6. But now when I run the python --version in the terminal I still see 3.8. I, unfortunately, can't remember what I've done. I might have made 'python' an alias, but I can't find where.
There is no alias for Python in ~/.bashrc
Can somebody make sense of the mess I've made? I'm happy to share additional information.
How do I upgrade, and how do I downgrade to Python 3.6?