首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在处理过程中遇到错误:汞-常见的

在处理过程中遇到错误:汞-常见的
EN

Ask Ubuntu用户
提问于 2021-11-08 08:23:56
回答 1查看 694关注 0票数 -4

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

在意识到我的错误之后,我从源代码重新安装了python3.8python2.7。Python现在正在工作。

我从这里那里得到了一些帮助。

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

但是,每当我试图通过apt安装任何其他软件包时,就会发生这样的情况:

代码语言:javascript
复制
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,结果是:

代码语言:javascript
复制
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,结果是:

代码语言:javascript
复制
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

代码语言:javascript
复制
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 make install安装mercurial (如页面中所示),结果是:

代码语言:javascript
复制
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的S .deb并在ubuntu上安装它:

代码语言:javascript
复制
$ 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

就像被问到的,我试过:

代码语言:javascript
复制
cd /var/cache/apt/archives/ && sudo rm -rf *.deb
sudo apt --purge autoremove mercurial\*

(我正在使用zsh,所以mercurial*不起作用),结果是:

代码语言:javascript
复制
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)

还尝试重新安装:

代码语言:javascript
复制
$ 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)

还有参考资料:(依赖于python2,我已经安装了它。

代码语言:javascript
复制
$ 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
EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2021-11-08 10:53:33

安装python2.7后,python3.7从头开始。我在pyclean中安装了pip2。我还必须安装pip2,所以我做了

代码语言:javascript
复制
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
python2 get-pip.py

然后通过以下方法去除汞的dpkg:

代码语言:javascript
复制
sudo rm -rf /var/lib/dpkg/info/mercurial*

然后我尝试重新安装mercurial:

代码语言:javascript
复制
sudo apt install --reinstall  mercurial mercurial-common

但直到我这么做了才起作用:

代码语言:javascript
复制
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更新/安装/升级运行良好。感谢所有的评论。

票数 -3
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1374246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档