Sudo apt upgrade doesn't work !! unmet dependencies Python 3
Solution 1
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?
Solution 2
Easiest method:
sudo apt-get install aptitude-common libcwidget3v5
sudo aptitude upgrade
OR
sudo apt-get install python3-distutils
Related videos on Youtube
Aaron Flierl
Updated on September 18, 2022Comments
-
Aaron Flierl over 1 year
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 didsudo apt upgrade
I received the error message below. I tried to dosudo apt --fix-broken install
and a sub-process returned an error code.
When i triedsudo apt upgrade
OutputReading 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
OutputReading 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
OutputReading 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
OutputReading 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).
-
bhordupur about 4 yearsTry this first
sudo apt update -y sudo apt clean sudo apt autoremove
and thensudo apt --fix-broken install
-
Raffa about 4 yearsDoes this answer your question? Removed python3 hoping to reinstall it, but cannot do it
-
Raffa about 4 yearsAlso you might want to try option #2 in this answer
-
user535733 about 4 yearsLooks like you tried to use packages from two different (and incompatible) sources: Example:
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
. Pick one source, delete the other source, and uninstall ALL packages from the deleted source. -
Raffa about 4 yearsPlease indicate what version of Ubuntu you are running and add the output of
cat /etc/apt/sources.list
-
Fusseldieb over 2 yearsIn my case a
sudo dpkg -i --force-overwrite "/var/cache/apt/archives/python3-lib2to3...deb"
did the trick, as suggested [ubuntuforums.org/…. Obviously, first do als /var/cache/apt/archives/
to see which filename it has and place it in the command. This has worked with all failed packages which saidwhich is also in package
.
-
-
bhordupur about 4 yearsWhy would you upgrade the distro? He wanted to upgrade only packages not the Ubuntu distribution.
-
Artur Meinild about 4 yearsdist-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.
-
bhordupur about 4 yearsdist-upgrade will aslo remove packages but upgrade wont
-
Aaron Flierl about 4 yearsAfter doing the suggestions mentioned I still am getting the same errors. Particularly, I get these errors after doing sudo apt --fix-broken install:
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
-
Artur Meinild about 4 yearsDid you run sudo apt clean ?? Because this should remove all packages in var/cache/apt/archives