7

Ubuntu: 18.04

When I tried to do sudo apt-get upgrade it gives me this error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  libpython3.7-minimal libpython3.7-stdlib
Use 'sudo apt autoremove' to remove them.
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python3-software-properties (0.96.24.32.7) ...
/var/lib/dpkg/info/python3-software-properties.postinst: 6: /var/lib/dpkg/info/python3-software-properties.postinst: py3compile: not found
dpkg: error processing package python3-software-properties (--configure):
 installed python3-software-properties package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 python3-software-properties
E: Sub-process /usr/bin/dpkg returned an error code (1)

But suggested commend sudo apt autoremove also shows error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED
  libpython3.7-minimal libpython3.7-stdlib
0 to upgrade, 0 to newly install, 2 to remove and 0 not to upgrade.
1 not fully installed or removed.
After this operation, 12.1 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 178285 files and directories currently installed.)
Removing libpython3.7-stdlib:amd64 (3.7.1-1~18.04) ...
Removing libpython3.7-minimal:amd64 (3.7.1-1~18.04) ...
Setting up python3-software-properties (0.96.24.32.7) ...
/var/lib/dpkg/info/python3-software-properties.postinst: 6: /var/lib/dpkg/info/python3-software-properties.postinst: py3compile: not found
dpkg: error processing package python3-software-properties (--configure):
 installed python3-software-properties package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 python3-software-properties
E: Sub-process /usr/bin/dpkg returned an error code (1)

So it looks like there is some problem with py3compile which is not found. I try sudo apt-get -f install which ends with:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python3-software-properties (0.96.24.32.7) ...
/var/lib/dpkg/info/python3-software-properties.postinst: 6: /var/lib/dpkg/info/python3-software-properties.postinst: py3compile: not found
dpkg: error processing package python3-software-properties (--configure):
 installed python3-software-properties package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 python3-software-properties
E: Sub-process /usr/bin/dpkg returned an error code (1)

The same kind of py3compile: not found error shows when i try sudo apt-get install --reinstall python3-minimal

I'm new with ubuntu so I will be glad for some help with that.

1
  • It may be worth trying to remove packages one by one, for example like this: sudo apt remove libpython3.7-minimal
    – Elias
    Apr 7, 2019 at 11:15

3 Answers 3

17

dpkg error: pycompile: not found - Stack Overflow

This answer helped me, hope it resolves someones problem.

Reconfigure all unpacked, but unconfigured packages by:

sudo dpkg --configure -a

If above won't help, try reinstalling python3-minimal package by:

sudo apt install -f --reinstall python3-minimal

Alternatively run:

apt-get download python3-minimal
sudo dpkg -i *python3*.deb
sudo apt install -f

Or download the .pkg file from kernel.org and install from the file by:

sudo dpkg -i python3-minimal_*.deb
2
  • Please include essential parts here.
    – user833907
    May 26, 2019 at 13:59
  • 1
    This did not help, I still get the same errors. Please include more info.
    – txs
    Oct 28, 2021 at 4:29
4

I got the problem of py3compile not found in Ubuntu 20.04.1 while installing python3-pip. I reinstalled python3-minimal as suggested by the answer and then again tried to installed python3-pip and it worked !

sudo apt install -f --reinstall python3-minimal

sudo apt install -f --reinstall python3-pip

Hope this helps someone in future !

-4

In my case i was upgrading Ubuntu 16. My solution was to set the default /usr/bin/python back to python2 as python3 did not have all dependencies needed.

rm /usr/bin/python /usr/bin/python3
ln -sf /usr/bin/python2.7 /usr/bin/python
3
  • This technique is perilous, particularly on multi-user systems, and should be applied with caution.
    – James S.
    Aug 25, 2021 at 19:51
  • 1
    Yes, this is only an exception for the Ubuntu 16 Upgrade, no usual method! The links will be corrected within the upgrade.
    – Dave
    Aug 27, 2021 at 7:05
  • 1
    Many modern applications depend on Python3 syntax. DO NOT USE THIS METHOD on 18.04 or above! This will throw more and more syntax errors.
    – Error404
    Feb 2 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.