Ubuntu apt-get upgrade报错问题
在ubuntu16.04中对源进行upgrade时报错:
ubuntu@SIFT-SYS-7048GR-TR:~$ sudo apt-get upgrade [sudo] password for ubuntu: Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 3 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] Setting up python-gi (3.20.0-0ubuntu1) ... /var/lib/dpkg/info/python-gi.postinst: 6: /var/lib/dpkg/info/python-gi.postinst: pycompile: not found dpkg: error processing package python-gi (--configure): subprocess installed post-installation script returned error exit status 127 dpkg: dependency problems prevent configuration of alacarte: alacarte depends on python-gi (>= 3.0); however: Package python-gi is not configured yet. dpkg: error processing package alacarte (--configure): dependency problems - leaving unconfigured Setting up python-opencv (2.4.9.1+dfsg-1.5ubuntu1) ... No apport report written because the error message indicates its a followup error from a previous failure. /var/lib/dpkg/info/python-opencv.postinst: 6: /var/lib/dpkg/info/python-opencv.postinst: pycompile: not found dpkg: error processing package python-opencv (--configure): subprocess installed post-installation script returned error exit status 127 Errors were encountered while processing: python-gi alacarte python-opencv E: Sub-process /usr/bin/dpkg returned an error code (1) ubuntu@SIFT-SYS-7048GR-TR:~$ sudo dpkg -C The following packages have been unpacked but not yet configured. They must be configured using dpkg --configure or the configure menu option in dselect for them to work: alacarte easy GNOME menu editing tool The following packages are only half configured, probably due to problems configuring them the first time. The configuration should be retried using dpkg --configure <package> or the configure menu option in dselect: python-gi Python 2.x bindings for gobject-introspection libraries python-opencv Python bindings for the computer vision library ubuntu@SIFT-SYS-7048GR-TR:~$ sudo dpkg --configure python-gi Setting up python-gi (3.20.0-0ubuntu1) ... /var/lib/dpkg/info/python-gi.postinst: 6: /var/lib/dpkg/info/python-gi.postinst: pycompile: not found dpkg: error processing package python-gi (--configure): subprocess installed post-installation script returned error exit status 127 Errors were encountered while processing: python-gi ubuntu@SIFT-SYS-7048GR-TR:~$ sudo apt-get install --reinstall apport Reading package lists... Done Building dependency tree Reading state information... Done 0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded. 3 not fully installed or removed. Need to get 120 kB of archives. After this operation, 0 B of additional disk space will be used. Get:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 apport all 2.20.1-0ubuntu2.10 [120 kB] Fetched 120 kB in 0s (684 kB/s) (Reading database ... 290222 files and directories currently installed.) Preparing to unpack .../apport_2.20.1-0ubuntu2.10_all.deb ... /var/lib/dpkg/info/apport.prerm: 19: /var/lib/dpkg/info/apport.prerm: pyclean: not found dpkg: warning: subprocess old pre-removal script returned error exit status 127 dpkg: trying script from the new package instead ... /var/lib/dpkg/tmp.ci/prerm: 19: /var/lib/dpkg/tmp.ci/prerm: pyclean: not found dpkg: error processing archive /var/cache/apt/archives/apport_2.20.1-0ubuntu2.10_all.deb (--unpack): subprocess new pre-removal script returned error exit status 127 /var/lib/dpkg/info/apport.postinst: 13: /var/lib/dpkg/info/apport.postinst: pycompile: not found dpkg: error while cleaning up: subprocess installed post-installation script returned error exit status 127 Errors were encountered while processing: /var/cache/apt/archives/apport_2.20.1-0ubuntu2.10_all.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
其中反复出现
/var/lib/dpkg/info/apport.postinst: 13: /var/lib/dpkg/info/apport.postinst: pycompile: not found
解决方法:
所以,很可能是python和apport出问题了
然后,Google相关的信息,得到的结果是apport和python需要重装,相关链接:package-management和dpkg returned an error code,相关的名令如下:
重装python:
sudo apt-get -m --reinstall install python python-minimal dh-python
sudo apt-get -f install
重装apport:
sudo apt-get update
sudo apt-get install --reinstall apport
sudo apt-get -f install
sudo apt-get dist-upgrade
结果:
ubuntu@SIFT-SYS-7048GR-TR:~$ sudo apt-get upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.