1

I get an error when I typed;

sudo apt upgrade

The error is;

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 python3-dev : Depends: python3-distutils (>= 3.10.6-1~) but 3.10.4-0ubuntu1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

If I try to type;

sudo apt --fix-broken install

The issue didn't solved and I get same error.

"apt policy python3-distutils" report is below;

python3-distutils:
  Installed: 3.10.4-0ubuntu1
  Candidate: 3.10.6-1~22.04
  Version table:
     3.10.6-1~22.04 500
        500 http://tr.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        500 http://tr.archive.ubuntu.com/ubuntu jammy-updates/main i386 Packages
 *** 3.10.4-0ubuntu1 500
        500 http://tr.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
        500 http://tr.archive.ubuntu.com/ubuntu jammy/main i386 Packages
        100 /var/lib/dpkg/status

"sudo apt --fix-broken install" also gave error such below;

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  python3-distutils python3-lib2to3
The following packages will be upgraded:
  python3-distutils python3-lib2to3
2 upgraded, 0 newly installed, 0 to remove and 25 not upgraded.
9 not fully installed or removed.
Need to get 0 B/216 kB of archives.
After this operation, 105 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 319749 files and directories currently installed.)
Preparing to unpack .../python3-distutils_3.10.6-1~22.04_all.deb ...
Unpacking python3-distutils (3.10.6-1~22.04) over (3.10.4-0ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/python3-distutils_3.10.6-
1~22.04_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.11/distutils/README', which is also in pa
ckage python3.11-distutils 3.11.0~rc2-1+jammy1
Preparing to unpack .../python3-lib2to3_3.10.6-1~22.04_all.deb ...
Unpacking python3-lib2to3 (3.10.6-1~22.04) over (3.10.4-0ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/python3-lib2to3_3.10.6-1~
22.04_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.11/lib2to3/Grammar.txt', which is also in
 package python3.11-lib2to3 3.11.0~rc2-1+jammy1
Errors were encountered while processing:
 /var/cache/apt/archives/python3-distutils_3.10.6-1~22.04_all.deb
 /var/cache/apt/archives/python3-lib2to3_3.10.6-1~22.04_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
7
  • Please run sudo apt update first and then run sudo apt upgrade again. Commented Sep 27, 2022 at 14:45
  • unfortunatelly that that didn't solve the issue Commented Sep 27, 2022 at 14:51
  • Please add the output of apt policy python3-distutils via edit to your question. Commented Sep 27, 2022 at 15:21
  • The required version of python3-distutils is availabe, so sudo apt --fix-broken install should be able to solve the dependency problem now. Please try again. Commented Sep 27, 2022 at 15:48
  • 1
    sorry but "sudo apt --fix-broken install" did not solved the issue. Commented Sep 27, 2022 at 15:53

1 Answer 1

1

I had the same error on my system. Turns out there was a conflict between python3.11 and python3.10. Running these fixed it for me.

sudo dpkg -r python3.11-distutils
sudo dpkg -r python3.11-lib2to3
sudo apt --fix-broken install

I found it by attempting to install the troublesome packages manually and getting more detailed error messages.

When I tried installing python3-distutils, apt said it couldn't install pyhton3-lib2to3. So I downloaded the deb from here.

After that I got a long error message with this at the end:

dpkg: error processing archive /var/cache/apt/archives/python3-lib2to3_3.10.6-
1~22.04_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.11/lib2to3/Grammar.txt', which is also 
in package python3.11-lib2to3 3.11.0~rc2-1+jammy1
Errors were encountered while processing:
 /var/cache/apt/archives/python3-distutils_3.10.6-1~22.04_all.deb
 /var/cache/apt/archives/python3-lib2to3_3.10.6-1~22.04_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

So that was my clue to remove python3.11-lib2to3. Hopefully the three commands above fixes your issue or it is something similar.

4
  • I couldn't remove those debs because of dependency issues so I ran: $ sudo apt remove python3.11 The following packages have unmet dependencies. python3-dev : Depends: python3-distutils ... python3-venv : Depends: python3-distutils ... python3.11-dev : Depends: python3.11 ... python3.11-venv : Depends: python3.11 ... eventually the full command was sudo apt remove python3.11 python3.11-dev python3.11-venv python3-dev python3-venv pipx python3-pythran python3-scipy python3-fonttools python3-ufolib2 python3-matplotlib mu-editor Commented Oct 7, 2022 at 9:56
  • Oh thanks. I have had a achievement. 'python3-distutilsis' fixed. But I still get error code when type 'sudo apt upgrade'. The error code is; 'dpkg: error processing archive /var/cache/apt/archives/python3-lib2to3_3.10.6-1~ 22.04_all.deb (--unpack):<br/>trying to overwrite '/usr/lib/python3.11/lib2to3/Grammar.txt', which is also in package python3.11-lib2to3 3.11.0~rc2-1+jammy1<br/> Errors were encountered while processing: <br/>/var/cache/apt/archives/python3-lib2to3_3.10.6-1~22.04_all.deb>br/>E: Sub-process /usr/bin/dpkg returned an error code (1)' Commented Oct 7, 2022 at 11:22
  • I just fix it at Synaptic Packace Manager. python3-distutils was broken and it SPM gave error message. First of all I marked it for complete removal. SPM gave error message but I don't remember it. Then on terminal I typed sudo apt --fix-broken install. Then the issues have gone copletely. Thanks for your help. Commented Oct 7, 2022 at 11:38
  • Similar issue with 3.10 and this one was the only thing that solved it. My X was not starting. This post saved my OS. Commented Aug 24, 2023 at 13:07

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.