0

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?

1 Answers1

-1

I just had this and other issues yesterday and was able to upgrade, here is what I did:

Go on https://wiki.ubuntu-it.org/Repository/SourcesList and take the sources to the next release to yours, do not try to do jumps to higher releases if you don't want to risk to brick your system. Stuff has to be done gradually. After getting the right sources copy them, then in the terminal: sudo nautilus

Then go on /etc/apt/sources.list copy this file to some directory you can access like ~/Downloads then edit it with gedit or an editor of your choice, then paste the content you copied from the previous site I linked. After that return to the terminal:

sudo apt update
sudo apt upgrade
sudo apt-get dist-upgrade
sudo systemctl reboot #  or simply reboot from the GUI
karel
  • 122,292
  • 133
  • 301
  • 332