由於 apport 錯誤,無法再使用 apt-get 進行安裝

由於 apport 錯誤,無法再使用 apt-get 進行安裝

我正在使用帶有 Xubuntu(Ubuntu 14.04.2 LTS,64 位元)Virtual Box 的 Windows 7 PC。最近,我在使用“apt-get”命令以及軟體更新程式時遇到了問題。軟體更新程式無法下載其中一項更新 - 我已同意 2.14.1-0ubuntu3.10,它正在嘗試安裝 2.14.1-0ubuntu3.11,但失敗。

另外,當我輸入任何類型的“apt-get”或“dpkg”命令(例如“apt-get update”)時,我會收到如下錯誤,有人知道我能做什麼嗎?

Reading package lists...
Building 
dependency tree...
Reading state information...
The following packages will be upgraded:
  apport
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
Need to get 0 B/180 kB of archives.
After this operation, 20.5 kB of additional disk space will be used.
Do you want to continue? [Y/n] (Reading database ... 314480 files and directories currently installed.)
Preparing to unpack .../apport_2.14.1-0ubuntu3.11_all.deb ...
initctl: Unknown job: apport
  File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
initctl: Unknown job: apport
  File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: error processing archive /var/cache/apt/archives/apport_2.14.1-0ubuntu3.11_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 35, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/apport_2.14.1-0ubuntu3.11_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

我只是嘗試在我的電腦上編譯python文件/usr/bin/pyclean,我用python3編譯它並得到相同的錯誤,而當我用python2編譯它時沒有錯誤。

所以,我猜你改變了系統中的一些東西,使得預設的 python 版本為 python3。

您可以嘗試像這樣解決這個問題:

  • 執行命令ls -l /usr/bin/python並查看其輸出。
  • 如果檔案/usr/bin/python指向 python3.x ,則刪除該連結並將其替換為 python2 的鏈接

    sudo rm /usr/bin/python
    sudo ln -s /usr/bin/python2.7 /usr/bin/python
    

    現在 python2.7 將作為系統中的預設 python 版本回歸

相關內容