ubuntu軟件中心打不開No module named 'apt_pkg'

故事的起源:最近看了《黑客與畫家》,決定要學個動態語言,但lisp難點,ruby又是鬼子搞的,因此選了pythonubuntu12.10python的默認版本是2.7,但我看最新的是3.3,因而,更新癖再犯,各類搜索,安裝了3.3版,但在終端輸入」python」,默認打開的仍是2.7,我豈能容忍? python

rm /usr/bin/python 數據庫

ln -s /usr/bin/python3.3 /usr/bin/python ubuntu

將默認打開版本換成了3.3.這也成了我倒黴的開端……以後,軟件中心打不開,ubuntu tweak也打不開(實際上,此時依賴python的程序都不行了) api

root@SHIT :# software-center
ruby

File "/usr/bin/software-center", line 140 session

print time.time() app

^ python2.7

SyntaxError: invalid syntax post

Error in sys.excepthook: ui

Traceback (most recent call last):

File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 64, in apport_excepthook

from apport.fileutils import likely_packaged, get_recent_crashes

File "/usr/lib/python3/dist-packages/apport/__init__.py", line 4, in <module>

from apport.report import Report

File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>

import apport.fileutils

File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>

from apport.packaging_impl import impl as packaging

File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 20, in <module>

import apt

File "/usr/lib/python3/dist-packages/apt/__init__.py", line 21, in <module>

import apt_pkg

ImportError: No module named 'apt_pkg'


Original exception was:

File "/usr/bin/software-center", line 140

print time.time()

^

SyntaxError: invalid syntax


搜索「ubuntu軟件中心沒法打開」,找到一下的解決方案:

gedit /etc/lsb-release

用如下內容替換其中的文本:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.10
DISTRIB_CODENAME=oneiric
DISTRIB_DESCRIPTION=「Ubuntu 12.10″

軟件中心是打開,頁面卻一直處於空白的刷新界面。

卸載重裝

apt-get autoremove software-center --purge

apt-get install software-center

apt-get --reinstall install software-center

仍是不行……不是這的問題,是python的問題

google一下,找到這個

http://stackoverflow.com/questions/13708180/python-dev-installation-error-importerror-no-module-named-apt-pkg

先移除,即 apt-get remove --purge python-apt

而後安裝 apt-get install python-apt


root@SHIT :# apt-get install python-apt

正在讀取軟件包列表... 完成

正在分析軟件包的依賴關係樹

正在讀取狀態信息... 完成

python-apt 已是最新的版本了。

升級了 0 個軟件包,新安裝了 0 個軟件包, 要卸載 0 個軟件包,有 0 個軟件包未被升級。

root@SHIT :# apt-get remove --purge python-apt

正在讀取軟件包列表... 完成

正在分析軟件包的依賴關係樹

正在讀取狀態信息... 完成

下列軟件包是自動安裝的而且如今不須要了:

gir1.2-unique-3.0 libunique-3.0-0

Use 'apt-get autoremove' to remove them.

下列軟件包將被【刪除】:

apt-xapian-index* flashplugin-installer* gdebi* gdebi-core*

gir1.2-ubuntuoneui-3.0* gnome-control-center*

gnome-control-center-signon* indicator-datetime*

indicator-power* landscape-client-ui-install*

libsyncdaemon-1.0-1* libubuntuoneui-3.0-1* oneconf*

python-apport* python-apt* python-aptdaemon*

python-aptdaemon.gtk3widgets* sessioninstaller*

software-center* ttf-mscorefonts-installer*

ubuntu-release-upgrader-gtk* ubuntu-system-service*

ubuntu-tweak* ubuntuone-client* ubuntuone-client-gnome*

ubuntuone-control-panel* ubuntuone-control-panel-qt*

update-manager* update-notifier* update-notifier-common*

升級了 0 個軟件包,新安裝了 0 個軟件包, 要卸載 30 個軟件包,有 0 個軟件包未被升級。

解壓縮後將會空出 25.4 MB 的空間。

您但願繼續執行嗎?[Y/n] y

dpkg:警告:files list file for package 'libxcomposite-dev' missing; assuming package has no files currently installed

dpkg:警告:files list file for package 'gnome-power-manager' missing; assuming package has no files currently installed

……

……

……

dpkg:警告:files list file for package 'libmono-system-data4.0-cil' missing; assuming package has no files currently installed

dpkg:警告:files list file for package 'xserver-xorg-input-vmmouse' missing; assuming package has no files currently installed

(正在讀取數據庫 ... 系統當前共安裝有 81 個文件和目錄。)

正在解壓縮 python-apt (.../python-apt_0.8.7ubuntu4_i386.deb) ...

正在設置 python-apt (0.8.7ubuntu4) ...

Traceback (most recent call last):

File "/usr/bin/pycompile", line 36, 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'

Error in sys.excepthook:

Traceback (most recent call last):

File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 64, in apport_excepthook

from apport.fileutils import likely_packaged, get_recent_crashes

File "/usr/lib/python3/dist-packages/apport/__init__.py", line 4, in <module>

from apport.report import Report

File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>

import apport.fileutils

File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>

from apport.packaging_impl import impl as packaging

File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 20, in <module>

import apt

File "/usr/lib/python3/dist-packages/apt/__init__.py", line 21, in <module>

import apt_pkg

ImportError: No module named 'apt_pkg'


Original exception was:

Traceback (most recent call last):

File "/usr/bin/pycompile", line 36, 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 processing python-apt (--configure):

子進程 已安裝 post-installation 腳本 返回了錯誤號 1

在處理時有錯誤發生:

python-apt

E: Sub-process /usr/bin/dpkg returned an error code (1)


root@SHIT :~# apt-get upgrade

正在讀取軟件包列表... 完成

正在分析軟件包的依賴關係樹

正在讀取狀態信息... 完成

升級了 0 個軟件包,新安裝了 0 個軟件包, 要卸載 0 個軟件包,有 0 個軟件包未被升級。

1 個軟件包沒有被徹底安裝或卸載。

解壓縮後會消耗掉 0 B 的額外空間。

您但願繼續執行嗎?[Y/n] y

正在設置 python-apt (0.8.7ubuntu4) ...

Traceback (most recent call last):

File "/usr/bin/pycompile", line 36, 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'

Error in sys.excepthook:

Traceback (most recent call last):

File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 64, in apport_excepthook

from apport.fileutils import likely_packaged, get_recent_crashes

File "/usr/lib/python3/dist-packages/apport/__init__.py", line 4, in <module>

from apport.report import Report

File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>

import apport.fileutils

File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>

from apport.packaging_impl import impl as packaging

File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 20, in <module>

import apt

File "/usr/lib/python3/dist-packages/apt/__init__.py", line 21, in <module>

import apt_pkg

ImportError: No module named 'apt_pkg'


Original exception was:

Traceback (most recent call last):

File "/usr/bin/pycompile", line 36, 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 processing python-apt (--configure):

子進程 已安裝 post-installation 腳本 返回了錯誤號 1

因爲已經達到 MaxReports 限制,沒有寫入 apport 報告。

在處理時有錯誤發生:

python-apt

E: Sub-process /usr/bin/dpkg returned an error code (1)


還不行,可是,忽然獲得神明指點,想起了我原來把python的默認運行版本改了!我靠,就是這的問題,這下好辦了,把python的版本改回來應該就行了


root@SHIT :~# rm /usr/bin/python

root@SHIT :~# ln -s /usr/bin/python2.7 /usr/bin/python


root@SHIT :~# apt-get install -f    ##即使完整性檢查失敗了仍然繼續,也就是接着安裝未完成的包


正在讀取軟件包列表... 完成

正在分析軟件包的依賴關係樹

正在讀取狀態信息... 完成

下列軟件包是自動安裝的而且如今不須要了:

gir1.2-unique-3.0 libunique-3.0-0

Use 'apt-get autoremove' to remove them.

升級了 0 個軟件包,新安裝了 0 個軟件包, 要卸載 0 個軟件包,有 0 個軟件包未被升級。

1 個軟件包沒有被徹底安裝或卸載。

解壓縮後會消耗掉 0 B 的額外空間。

正在設置 python-apt (0.8.7ubuntu4) ...

root@SHIT :~# apt-get install -f

正在讀取軟件包列表... 完成

正在分析軟件包的依賴關係樹

正在讀取狀態信息... 完成

下列軟件包是自動安裝的而且如今不須要了:

gir1.2-unique-3.0 libunique-3.0-0

Use 'apt-get autoremove' to remove them.

升級了 0 個軟件包,新安裝了 0 個軟件包, 要卸載 0 個軟件包,有 0 個軟件包未被升級。


點擊ubuntu軟件中心,再也不是閃幾下就趴窩了,久違的界面啓動了

相關文章
相關標籤/搜索