1

I was having an error doing normal ubuntu(18) updates related to ValueError: bad marshal data

I deleted pyc files in /usr as suggested but no joy. I tried removing and reinstalling python - but hit this problem:

jon@:/var/www/stats/pup$ sudo apt install --reinstall python3-apt
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
 apport : Depends: python3-apport (>= 2.20.9-0ubuntu7.21) but 2.20.9-0ubuntu7.20 is to be installed
 apport-gtk : Depends: python3-apport (>= 2.20.9-0ubuntu7.21) but 2.20.9-0ubuntu7.20 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

I tried apt --fix-broken install but this fails:

(Reading database ... 320885 files and directories currently installed.)
Preparing to unpack .../python3-apport_2.20.9-0ubuntu7.21_all.deb ...
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1159, in _install
ValueError: bad marshal data (unknown type code)
Fatal Python error: Py_Initialize: importlib install failed

Current thread 0x00007fd7fedd1740 (most recent call first): Aborted dpkg: warning: old python3-apport package pre-removal script subprocess returned error exit status 134 dpkg: trying script from the new package instead ... Traceback (most recent call last): File "<frozen importlib._bootstrap>", line 1159, in _install ValueError: bad marshal data (unknown type code) Fatal Python error: Py_Initialize: importlib install failed

Current thread 0x00007f5f2bcdf740 (most recent call first): Aborted dpkg: error processing archive /var/cache/apt/archives/python3-apport_2.20.9-0ubuntu7.21_all.deb (--unpack): new python3-apport package pre-removal script subprocess returned error exit status 134 Traceback (most recent call last): File "<frozen importlib._bootstrap>", line 1159, in _install ValueError: bad marshal data (unknown type code) Fatal Python error: Py_Initialize: importlib install failed

Current thread 0x00007faebc356740 (most recent call first): Aborted dpkg: error while cleaning up: installed python3-apport package post-installation script subprocess returned error exit status 134 Errors were encountered while processing: /var/cache/apt/archives/python3-apport_2.20.9-0ubuntu7.21_all.deb E: Sub-process /usr/bin/dpkg returned an error code (1)

jons
  • 53
  • 1
  • @raffa Thanks but trying to install aptitude fails with same reason: $ python3 --version Python 3.6.9 $ sudo apt install aptitude Reading package lists... Done Building dependency tree
    Reading state information... Done You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies. apport : Depends: python3-apport (>= 2.20.9-0ubuntu7.21) but 2.20.9-0ubuntu7.20 is to be installed
    – jons Jan 04 '21 at 10:51
  • apport-gtk : Depends: python3-apport (>= 2.20.9-0ubuntu7.21) but 2.20.9-0ubuntu7.20 is to be installed aptitude : Depends: aptitude-common (= 0.8.10-6ubuntu1) but it is not going to be installed Depends: libcwidget3v5 but it is not going to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution). – jons Jan 04 '21 at 10:53

1 Answers1

3

Removing python is never a good idea as it is vital for the system's functionality.

I would recommend installing aptitude and using it to install python3 for APT to properly work again. Aptitude is good at resolving dependencies and it has been used in similar cases to successfully install python3 after it was removed.

If the solution in this post didn't work for you, I would suggest you try fixing from a live USB ( like the one you used to install Ubuntu).

To fix from a live USB, boot into the live system and select try Ubuntu then connect to Internet from the live system and open a terminal then follow these steps:

Run:

sudo fdisk -l

And identify your root partition. It could be something like /dev/sda1 then mount it to /mnt like so:

sudo mount /dev/sda1 /mnt/

Then run:

sudo mount --bind /proc/ /mnt/proc/

Then run:

sudo mount --bind /sys/ /mnt/sys/

Then run:

sudo mount --bind /dev/ /mnt/dev/

Then run:

sudo cp /etc/resolv.conf /mnt/etc/resolv.conf

Then run:

sudo chroot /mnt/

Now you are in your original system on the hard disk. Run this command:

sudo dpkg --configure -a && sudo apt update --fix-missing && sudo apt install -f --fix-broken

Then install aptitude like so:

sudo apt install aptitude

Or if that didn't work, download the aptitude .deb package from here for 64 bit like so:

sudo wget http://mirrors.kernel.org/ubuntu/pool/main/a/aptitude/aptitude_0.8.10-6ubuntu1_amd64.deb

And install it like so:

sudo dpkg -i aptitude_0.8.10-6ubuntu1_amd64.deb

Then run:

sudo aptitude install python3

When finished run:

exit

Then run:

sudo umount /mnt/dev/

Then run:

sudo umount /mnt/sys/

Then run:

sudo umount /mnt/proc/

Then run:

sudo umount /mnt/

Then reboot to your original system, and see if it is fixed. If this does not work, you probably need to reinstall Ubuntu.

Important:

If you get to the point where nothing worked and you decided to reinstall Ubuntu, make sure you backup all your important data to an external disk first.

Also to minimize loosing your settings, copy your home directory (/home/username/) with all its hidden directories and files to an external disk then copy it back again after the new install. This will keep most of your settings for applications i.e. Firefox, Thunderbird... etc but you will need to reinstall applications and packages you manually installed again for that to work.

Raffa
  • 32,237