5

I recently installed Python3.8 and everything worked fine as far as using various versions of Python successfully in the terminal. After several days I called sudo apt update, which worked just fine, but when I did sudo apt upgrade I received the error message below. I tried to do sudo apt --fix-broken install and a sub-process returned an error code.
When i tried sudo apt upgrade
Output

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:
dh-python : Depends: python3-distutils but it is not installed
python3-dev : Depends: python3-distutils (>= 3.6.7-1~) but it is not installed
python3-pip : Depends: python3-distutils but it is not installed
python3-setuptools : Depends: python3-distutils but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

When i tried sudo apt --fix-broken install
Output

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libllvm7 libllvm8 libllvm8:i386 libpython3.7-minimal libpython3.7-stdlib
  python3.7-minimal
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  python3-distutils python3-lib2to3
The following NEW packages will be installed:
  python3-distutils python3-lib2to3
0 upgraded, 2 newly installed, 0 to remove and 122 not upgraded.
10 not fully installed or removed.
Need to get 0 B/222 kB of archives.
After this operation, 3,143 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 201984 files and directories currently installed.)
Preparing to unpack .../python3-lib2to3_3.6.9-1~18.04_all.deb ...
Unpacking python3-lib2to3 (3.6.9-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-lib2to3_3.6.9-1~18.04_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.8/lib2to3/Grammar.txt', which is also in package python3.8-lib2to3 3.8.0-1+bionic2
Preparing to unpack .../python3-distutils_3.6.9-1~18.04_all.deb ...
Unpacking python3-distutils (3.6.9-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-distutils_3.6.9-1~18.04_all.deb (--unpack):
trying to overwrite '/usr/lib/python3.8/distutils/README', which is also in package python3.8-distutils 3.8.0-1+bionic2
Errors were encountered while processing:
 /var/cache/apt/archives/python3-lib2to3_3.6.9-1~18.04_all.deb
 /var/cache/apt/archives/python3-distutils_3.6.9-1~18.04_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I also tried to do this sudo apt --fix-broken install python3-distutils
Output

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:
 python3-distutils : Depends: python3-lib2to3 (>= 3.6.4) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).```

I also tried sudo apt --fix-broken install python3-lib2to3
Output

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:
 dh-python : Depends: python3-distutils but it is not going to be installed
 python3-dev : Depends: python3-distutils (>= 3.6.7-1~) but it is not going to be installed
 python3-pip : Depends: python3-distutils but it is not going to be installed
 python3-setuptools : Depends: python3-distutils but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Thanks for any help that can be provided!

Update

when I tried to do sudo apt install aptitude

Output

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:
 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
 dh-python : Depends: python3-distutils but it is not going to be installed
 python3-dev : Depends: python3-distutils (>= 3.6.7-1~) but it is not going to be installed
 python3-pip : Depends: python3-distutils but it is not going to be installed
 python3-setuptools : Depends: python3-distutils but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
Raffa
  • 32,237

3 Answers3

3

Try using the following instead:

sudo apt dist-upgrade 

Since dist-upgrade also handles new package dependencies.

This was explained here: Why use apt-get upgrade instead of apt-get dist-upgrade?

Artur Meinild
  • 26,018
  • Why would you upgrade the distro? He wanted to upgrade only packages not the Ubuntu distribution. – bhordupur Apr 14 '20 at 18:50
  • 1
    dist-upgrade has nothing to do with upgrading the distro/release. Try reading the link I just posted. If you want to upgrade the Ubuntu release you run the command: sudo do-release-upgrade, which is something entirely different than an apt command. – Artur Meinild Apr 14 '20 at 18:54
  • dist-upgrade will aslo remove packages but upgrade wont – bhordupur Apr 14 '20 at 18:59
  • After doing the suggestions mentioned I still am getting the same errors. Particularly, I get these errors after doing sudo apt --fix-broken install:
     /var/cache/apt/archives/python3-lib2to3_3.6.9-1~18.04_all.deb
     /var/cache/apt/archives/python3-distutils_3.6.9-1~18.04_all.deb```
    
    – Aaron Flierl Apr 14 '20 at 21:52
  • Did you run sudo apt clean ?? Because this should remove all packages in var/cache/apt/archives – Artur Meinild Apr 15 '20 at 08:57
2

Easiest method:

sudo apt-get install aptitude-common libcwidget3v5
sudo aptitude upgrade

OR

sudo apt-get install python3-distutils
0

There are many ways to solve this issue , if you want to upgrade but can't:

Way 1

Step 1 : open Software & Updates.

Step 2 : change Download from to Main Server

Step 3 : open Terminal (ctlr + alt + t) then sudo apt-get update , then sudo apt-get upgrade

Way 2 Remove PPA

Step 1 : open Software & Updates.

Step 2 : go to Other Software tab and choose the desire PPA from the list. Afterwards click on Remove to remove it.

OR

You can remove it using terminal : sudo apt-add-repository -r PPA_Name/ppa

Way 3 :

Read This

also try to use this commands , may it help: sudo apt clean , sudo apt autoclean , sudo apt autoremove.

Hope that helps you!

AEM
  • 1,166