处理时遇到错误:mercurial-common

处理时遇到错误:mercurial-common

我意外地从中删除了 python,/usr/bin因为它与 冲突/usr/local/bin。( rm -rf /usr/bin/python*)

意识到自己的错误后,我重新安装python3.8python2.7从源代码开始。 Python 现在可以正常工作了。

我得到了一些帮助这里

操作系统:Ubuntu 20.04,带有 KDE、ZSH

但是每当我尝试通过 apt 安装任何其他包时,都会发生以下情况:

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)

我尝试过sudo dpkg --configure -a,结果是:

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

我尝试过sudo apt-get install mercurial-common mercurial,结果是:


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)

我试过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)

我尝试安装 mercurial来源sudo make install(如页面所示)结束时是:

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

由于这个原因,我无法从 apt 安装任何包,也无法配置 mercurial。

我尝试下载mercurial-common.deb安装它,因为它在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

正如我所要求的,我尝试过:

cd /var/cache/apt/archives/ && sudo rm -rf *.deb
sudo apt --purge autoremove mercurial\*

(我正在使用zsh,因此mercurial*不起作用),导致:

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)

还尝试重新安装:

$ 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)

另供参考:(Mercurial依赖于 python2 并且我已经安装了它。

$ 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

答案1

安装后python2.7python3.7从头开始。我使用pyclean进行安装pip2。我还必须安装 pip2,所以我这样做了

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
python2 get-pip.py

然后通过以下方式删除 mercurial dpkg:

sudo rm -rf /var/lib/dpkg/info/mercurial*

然后我尝试重新安装 mercurial:

sudo apt install --reinstall  mercurial mercurial-common

但这并没有起作用,直到我这样做:

sudo apt-get -m --reinstall install python2.7 python2.7-minimal dh-python python3 python3-minimal 
sudo update-alternatives --install /usr/local/bin/python python /usr/local/bin/python3 12
sudo update-alternatives --install /usr/local/bin/python python /usr/local/bin/python2 11
sudo dpkg --configure -a 

现在 apt update/install/upgrade 工作正常。感谢所有评论。

相关内容