I accidentally removed python from /usr/bin
as it was conflicting with /usr/local/bin
. (rm -rf /usr/bin/python*
)
After realising my mistake i reinstall python3.8
and python2.7
from source. Python is now working.
I took some of the help from here.
OS: Ubuntu 20.04, with KDE, ZSH
But whenever i try to install any other package via apt this happens:
Setting up mercurial-common (5.3.1-1ubuntu1) ...
/var/lib/dpkg/info/mercurial-common.postinst: 8: pycompile: not found
dpkg: error processing package mercurial-common (--configure):
installed mercurial-common package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
mercurial-common
E: Sub-process /usr/bin/dpkg returned an error code (1)
I tried sudo dpkg --configure -a
which resulted in:
Setting up mercurial-common (5.3.1-1ubuntu1) ...
/var/lib/dpkg/info/mercurial-common.postinst: 8: pycompile: not found
dpkg: error processing package mercurial-common (--configure):
installed mercurial-common package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
mercurial-common
I tried sudo apt-get install mercurial-common mercurial
which resulted in:
Reading package lists... Done
Building dependency tree
Reading state information... Done
mercurial-common is already the newest version (5.3.1-1ubuntu1).
Suggested packages:
kdiff3 | kdiff3-qt | kompare | meld | tkcvs | mgdiff qct
The following NEW packages will be installed:
mercurial
0 upgraded, 1 newly installed, 0 to remove and 32 not upgraded.
1 not fully installed or removed.
Need to get 0 B/323 kB of archives.
After this operation, 1,092 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 564968 files and directories currently installed.)
Preparing to unpack .../mercurial_5.3.1-1ubuntu1_amd64.deb ...
Unpacking mercurial (5.3.1-1ubuntu1) ...
Setting up mercurial-common (5.3.1-1ubuntu1) ...
/var/lib/dpkg/info/mercurial-common.postinst: 8: pycompile: not found
dpkg: error processing package mercurial-common (--configure):
installed mercurial-common package post-installation script subprocess returned error exit status 127
dpkg: dependency problems prevent configuration of mercurial:
mercurial depends on mercurial-common (= 5.3.1-1ubuntu1); however:
Package mercurial-common is not configured yet.
dpkg: error processing package mercurial (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mercurial-common
mercurial
E: Sub-process /usr/bin/dpkg returned an error code (1)
I tried sudo apt-get install --fix-broken
:
Package mercurial-common is not configured yet.
dpkg: error processing package mercurial (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mercurial-common
mercurial
E: Sub-process /usr/bin/dpkg returned an error code (1)
I tried to install mercurial from source by sudo make install
(as on the page) the end was:
running install_scripts
copying build/scripts-3.8/hg -> /usr/local/bin
changing mode of /usr/local/bin/hg to 775
running install_egg_info
Removing /usr/local/lib/python3.8/site-packages/mercurial-5.9.3-py3.8.egg-info
Writing /usr/local/lib/python3.8/site-packages/mercurial-5.9.3-py3.8.egg-info
make -C doc
make[1]: Entering directory '/home/black/Downloads/mercurial-debian-master/doc'
python3 runrst hgmanpage --halt warning \
--strip-elements-with-class htmlonly hgrc.5.txt hgrc.5
abort: couldn't generate documentation: docutils module is missing
please install python-docutils or see http://docutils.sourceforge.net/
make[1]: *** [Makefile:33: hgrc.5] Error 255
make[1]: Leaving directory '/home/black/Downloads/mercurial-debian-master/doc'
make: *** [Makefile:81: doc] Error 2
╭─ ~/Downloads/mercurial-debian-mast
I am not able to install any package from apt because of this and i am not able to configure mercurial.
I tried downloading mercurial-common
's .deb
and installing it as it was on ubuntu:
$ apt-get download mercurial-common
$ sudo dpkg -i mercurial-common_5.3.1-1ubuntu1_all.deb
(Reading database ... 564985 files and directories currently installed.)
Preparing to unpack mercurial-common_5.3.1-1ubuntu1_all.deb ...
/var/lib/dpkg/info/mercurial-common.prerm: 12: pyclean: not found
dpkg: warning: old mercurial-common package pre-removal script subprocess returned error exit status 127
dpkg: trying script from the new package instead ...
/var/lib/dpkg/tmp.ci/prerm: 12: pyclean: not found
dpkg: error processing archive mercurial-common_5.3.1-1ubuntu1_all.deb (--install):
new mercurial-common package pre-removal script subprocess returned error exit status 127
/var/lib/dpkg/info/mercurial-common.postinst: 8: pycompile: not found
dpkg: error while cleaning up:
installed mercurial-common package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
mercurial-common_5.3.1-1ubuntu1_all.deb
As asked i tried:
cd /var/cache/apt/archives/ && sudo rm -rf *.deb
sudo apt --purge autoremove mercurial\*
(I am using zsh
, so mercurial*
wont work), resulted in:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'mercurial-keyring' for glob 'mercurial*'
Note, selecting 'mercurial-git' for glob 'mercurial*'
Note, selecting 'mercurial-buildpackage' for glob 'mercurial*'
Note, selecting 'mercurial-common' for glob 'mercurial*'
Note, selecting 'mercurial' for glob 'mercurial*'
Note, selecting 'mercurial-crecord' for glob 'mercurial*'
Note, selecting 'mercurial-extension-utils' for glob 'mercurial*'
Package 'mercurial-git' is not installed, so not removed
Package 'mercurial-buildpackage' is not installed, so not removed
Package 'mercurial-crecord' is not installed, so not removed
Package 'mercurial-extension-utils' is not installed, so not removed
Package 'mercurial-keyring' is not installed, so not removed
The following packages will be REMOVED:
mercurial* mercurial-common*
0 upgraded, 0 newly installed, 2 to remove and 32 not upgraded.
2 not fully installed or removed.
After this operation, 15.1 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 564985 files and directories currently installed.)
Removing mercurial (5.3.1-1ubuntu1) ...
dpkg: error processing package mercurial-common (--remove):
package is in a very bad inconsistent state; you should
reinstall it before attempting a removal
dpkg: too many errors, stopping
Errors were encountered while processing:
mercurial-common
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
Also tried reinstalling:
$ sudo apt-get install --reinstall mercurial mercurial-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
kdiff3 | kdiff3-qt | kompare | meld | tkcvs | mgdiff qct
The following NEW packages will be installed:
mercurial
0 upgraded, 1 newly installed, 1 reinstalled, 0 to remove and 32 not upgraded.
1 not fully installed or removed.
Need to get 2,973 kB of archives.
After this operation, 1,092 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 mercurial-common all 5.3.1-1ubuntu1 [2,650 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 mercurial amd64 5.3.1-1ubuntu1 [323 kB]
Fetched 2,973 kB in 5s (635 kB/s)
(Reading database ... 564968 files and directories currently installed.)
Preparing to unpack .../mercurial-common_5.3.1-1ubuntu1_all.deb ...
/var/lib/dpkg/info/mercurial-common.prerm: 12: pyclean: not found
dpkg: warning: old mercurial-common package pre-removal script subprocess returned error exit status 127
dpkg: trying script from the new package instead ...
/var/lib/dpkg/tmp.ci/prerm: 12: pyclean: not found
dpkg: error processing archive /var/cache/apt/archives/mercurial-common_5.3.1-1ubuntu1_all.deb (--unpack):
new mercurial-common package pre-removal script subprocess returned error exit status 127
/var/lib/dpkg/info/mercurial-common.postinst: 8: pycompile: not found
dpkg: error while cleaning up:
installed mercurial-common package post-installation script subprocess returned error exit status 127
Preparing to unpack .../mercurial_5.3.1-1ubuntu1_amd64.deb ...
Unpacking mercurial (5.3.1-1ubuntu1) ...
Errors were encountered while processing:
/var/cache/apt/archives/mercurial-common_5.3.1-1ubuntu1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Also for references: (Mercurial is depends on python2 and i have it installed.
$ which pycompile
/usr/bin/pycompile
$ which pyclean
/usr/bin/pyclean
$ which python2.7
/usr/local/bin/python2.7
$ ls -la /usr/local/bin/python*
-rwxr-xr-x 1 root root 5490488 Nov 8 00:17 /usr/local/bin/python
lrwxrwxrwx 1 root root 9 Nov 8 03:21 /usr/local/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 9795824 Nov 8 03:19 /usr/local/bin/python2.7
-rwxr-xr-x 1 root root 1687 Nov 8 03:19 /usr/local/bin/python2.7-config
lrwxrwxrwx 1 root root 16 Nov 8 03:21 /usr/local/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 9 Nov 8 15:36 /usr/local/bin/python3 -> python3.7
-rwxr-xr-x 2 root root 17917584 Nov 8 15:35 /usr/local/bin/python3.7
lrwxrwxrwx 1 root root 17 Nov 8 15:36 /usr/local/bin/python3.7-config -> python3.7m-config
-rwxr-xr-x 2 root root 17917584 Nov 8 15:35 /usr/local/bin/python3.7m
-rwxr-xr-x 1 root root 2902 Nov 8 15:36 /usr/local/bin/python3.7m-config
-rwxr-xr-x 1 root root 20551712 Nov 8 02:33 /usr/local/bin/python3.8
-rwxr-xr-x 1 root root 3087 Nov 8 02:33 /usr/local/bin/python3.8-config
lrwxrwxrwx 1 root root 16 Nov 8 15:36 /usr/local/bin/python3-config -> python3.7-config
apt
& package front-ends (likeapt
) no longer work;dpkg
would have let you install the correct deb package – guiverc Nov 08 '21 at 08:27.deb
for mercurial. – Black Chase Nov 08 '21 at 08:34cd /var/cache/apt/archives/ && sudo rm -rf *.deb
run this command and report back – Error404 Nov 08 '21 at 08:41sudo apt --purge autoremove mercurial*
– Error404 Nov 08 '21 at 08:42Added python2.7 to path for good measure and provided default output for various python versions order. Not sure what other support packages are needed as reinstalling didn't work. Refer last appends.
– Black Chase Nov 08 '21 at 10:20pyclean
andpycompile
bypip
orapt
then if the error is still there report back and maybe try this command toosudo rm -rf /var/lib/dpkg/info/mercurial*
– Error404 Nov 08 '21 at 10:27pyclean
, but forpycompile
:ERROR: Could not find a version that satisfies the requirement pycompile (from versions: none)
. After rm -rf, i tried purge removing mercurial, but this again: – Black Chase Nov 08 '21 at 10:38