2

I am trying to upgrade from 16.04.6 LTS to 18.04.3 LTS. apt-get update. upgrade, and dist-upgrade work without issue. But when I try to run do-release-upgrade it fails with the following error:

$ sudo do-release-upgrade
[sudo] password for punknubbins:
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 have looked online and tried everything I found. From reinstalling python3, to creating a link to point /usr/lib/python3/dist-packages/apt_pkg.cpython-34m-i386-linux-gnu.so to /usr/lib/python3/dist-packages/apt_pkg.cpython-35m-i386-linux-gnu.so, and finally to setting my default python3 to 3.4/3.5/3.6. None of which worked.

Now, this is a headless server running in a closet in an office across town so driving over, hooking up a monitor and keyboard, and upgrading from external media is frustratingly manual. Is there a way to just download the install ISO to this device and update it from that source? If not, what are we supposed to do when the automatic upgrade process doesn't work?

Zanna
  • 69,223
  • 56
  • 216
  • 327
Punknubbins
  • 21
  • 1
  • 2
  • 1
    Have you tried [**all**](https://askubuntu.com/questions/480908/problem-with-update-manager-no-module-named-apt-pkg-in-ubuntu-13-10-having-i) solutions listed here? – David Sep 02 '19 at 02:21
  • I have tried every suggestion in [the thread you linked to](https://askubuntu.com/questions/480908/problem-with-update-manager-no-module-named-apt-pkg-in-ubuntu-13-10-having-i) but something clearly isn't right. – Punknubbins Sep 02 '19 at 02:32
  • The release-upgrade process is tested with only Ubuntu repository software, so your best bet is to remove all 3rd party & PPA software, reboot, then release-upgrade, then add back the additional software you had decided you needed. – guiverc Sep 02 '19 at 02:33
  • Does this answer your question? [ModuleNotFoundError: No module named 'apt\_pkg' error](https://askubuntu.com/questions/1069087/modulenotfounderror-no-module-named-apt-pkg-error) – karel Feb 01 '20 at 16:58

1 Answers1

1

Try the following command:

$ sudo apt install --reinstall python3 python python3-minimal
$ sudo apt --fix-broken install

Followed by:

$ sudo apt update && sudo apt upgrade
$ sudo do-release-upgrade

Reboot:

$ sudo reboot     
Error404
  • 6,920
  • 1
  • 26
  • 50