Ubuntu 软件中心因 Python 代码错误而崩溃

Tad*_*eck 5 software-center python 12.04 12.10 13.04

我搜索了那个,但在这个网站上没有找到任何参考。如果你知道一些,请给我推荐 - 我看到的问题有不同的症状。所以,重点...

我有很长一段时间的 Ubuntu 12.04 LTS,切换到 Ubuntu Gnome Shell 等。最近我想转移到 Ubuntu 13.04,发现一个似乎以前发生过但似乎随机发生的问题。现在我根本无法启动 Ubuntu 软件中心。

当我运行控制台时,我看到:

$ software-center

(process:22270): Gtk-WARNING **: Locale not supported by C library.
    Using the fallback 'C' locale.
Traceback (most recent call last):
  File "/usr/bin/software-center", line 36, in <module>
    from softwarecenter.utils import (
  File "/usr/share/software-center/softwarecenter/utils.py", line 47, in <module>
    from config import get_config
  File "/usr/share/software-center/softwarecenter/config.py", line 33, in <module>
    class SoftwareCenterConfig(object, SafeConfigParser):
  File "/usr/lib/python2.7/abc.py", line 87, in __new__
    cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace)
TypeError: Error when calling the metaclass bases
    Cannot create a consistent method resolution
order (MRO) for bases SafeConfigParser, object
Run Code Online (Sandbox Code Playgroud)

我希望遵循这些想法(来源)可能会有所帮助:

$ sudo apt-get purge software-center
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo apt-get install software-center
$ sudo dpkg-reconfigure software-center --force
Run Code Online (Sandbox Code Playgroud)

不是:

$ sudo apt-get purge software-center
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  software-center-aptdaemon-plugins
Use 'apt-get autoremove' to remove it.
The following packages will be REMOVED:
  software-center*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? Y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 269627 files and directories currently installed.)
Removing software-center ...
Purging configuration files for software-center ...
rmdir: failed to remove `/var/cache/software-center/xapian/': No such file or directory
dpkg: error processing software-center (--purge):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 software-center
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?如何摆脱导致错误的 Ubuntu 软件中心并安装没有错误的版本?

或者问题出在我的 Python 解释器上?

$ python --version
Python 2.7.3
Run Code Online (Sandbox Code Playgroud)

我相信 Ubuntu 正在逐渐转向仅在 Python 3.x 上工作的工具,但这是原因吗?

感谢所有的提示。我坚信它可能对其他人也有帮助。

更新 1.:

第一次更新是从12.04到12.10,没注意到没有到13.04。我一注意到,我就从 12.10 升级到 13.04。然而问题并没有消失。

我也做了thefourtheye的要求

$ sudo locale-gen
Generating locales...
  en_US.UTF-8... up-to-date
Generation complete.
Run Code Online (Sandbox Code Playgroud)

这是尝试进行清除的结果:

$ sudo apt-get purge software-center
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  python-oneconf software-center-aptdaemon-plugins
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  software-center*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? Y
(Reading database ... 279036 files and directories currently installed.)
Removing software-center ...
Purging configuration files for software-center ...
rmdir: failed to remove ‘/var/cache/software-center/xapian/’: No such file or directory
dpkg: error processing software-center (--purge):
 subprocess installed post-removal script returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 software-center
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

更新 2.:

另一个调试信息(由 nickguletskii 请求):

$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
Run Code Online (Sandbox Code Playgroud)

$ sudo apt-get install language-pack-en
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  firefox-locale-en language-pack-en-base
The following NEW packages will be installed:
  firefox-locale-en language-pack-en language-pack-en-base
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,372 kB of archives.
After this operation, 4,874 kB of additional disk space will be used.
Do you want to continue [Y/n]? 
Get:1 http://security.ubuntu.com/ubuntu/ raring-security/main firefox-locale-en amd64 21.0+build2-0ubuntu0.13.04.2 [549 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ raring/main language-pack-en-base all 1:13.04+20130418 [822 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ raring/main language-pack-en all 1:13.04+20130418 [1,968 B]
Fetched 1,372 kB in 2s (521 kB/s)            
Selecting previously unselected package language-pack-en-base.
(Reading database ... 279503 files and directories currently installed.)
Unpacking language-pack-en-base (from .../language-pack-en-base_1%3a13.04+20130418_all.deb) ...
Selecting previously unselected package language-pack-en.
Unpacking language-pack-en (from .../language-pack-en_1%3a13.04+20130418_all.deb) ...
Selecting previously unselected package firefox-locale-en.
Unpacking firefox-locale-en (from .../firefox-locale-en_21.0+build2-0ubuntu0.13.04.2_amd64.deb) ...
Processing triggers for software-center ...
ERROR:root:DebFileApplication import
Traceback (most recent call last):
  File "/usr/share/software-center/softwarecenter/db/__init__.py", line 4, in <module>
    from debfile import DebFileApplication, DebFileOpenError
  File "/usr/share/software-center/softwarecenter/db/debfile.py", line 25, in <module>
    from softwarecenter.db.application import Application, AppDetails
  File "/usr/share/software-center/softwarecenter/db/application.py", line 28, in <module>
    import softwarecenter.distro
  File "/usr/share/software-center/softwarecenter/distro/__init__.py", line 26, in <module>
    from softwarecenter.utils import UnimplementedError, utf8
  File "/usr/share/software-center/softwarecenter/utils.py", line 48, in <module>
    from config import get_config
  File "/usr/share/software-center/softwarecenter/config.py", line 33, in <module>
    class SoftwareCenterConfig(object, SafeConfigParser):
  File "/usr/lib/python2.7/abc.py", line 87, in __new__
    cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace)
TypeError: Error when calling the metaclass bases
    Cannot create a consistent method resolution
order (MRO) for bases object, SafeConfigParser
Traceback (most recent call last):
  File "/usr/sbin/update-software-center", line 38, in <module>
    from softwarecenter.db.update import rebuild_database
  File "/usr/share/software-center/softwarecenter/db/update.py", line 33, in <module>
    from softwarecenter.backend.scagent import SoftwareCenterAgent
  File "/usr/share/software-center/softwarecenter/backend/scagent.py", line 28, in <module>
    from softwarecenter.distro import get_distro, get_current_arch
  File "/usr/share/software-center/softwarecenter/distro/__init__.py", line 26, in <module>
    from softwarecenter.utils import UnimplementedError, utf8
  File "/usr/share/software-center/softwarecenter/utils.py", line 48, in <module>
    from config import get_config
  File "/usr/share/software-center/softwarecenter/config.py", line 33, in <module>
    class SoftwareCenterConfig(object, SafeConfigParser):
  File "/usr/lib/python2.7/abc.py", line 87, in __new__
    cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace)
TypeError: Error when calling the metaclass bases
    Cannot create a consistent method resolution
order (MRO) for bases object, SafeConfigParser
Setting up firefox-locale-en (21.0+build2-0ubuntu0.13.04.2) ...
Setting up language-pack-en (1:13.04+20130418) ...
Setting up language-pack-en-base (1:13.04+20130418) ...
Generating locales...
  en_AG.UTF-8... done
  en_AU.UTF-8... done
  en_BW.UTF-8... done
  en_CA.UTF-8... done
  en_DK.UTF-8... done
  en_GB.UTF-8... done
  en_HK.UTF-8... done
  en_IE.UTF-8... done
  en_IN.UTF-8... done
  en_NG.UTF-8... done
  en_NZ.UTF-8... done
  en_PH.UTF-8... done
  en_SG.UTF-8... done
  en_US.UTF-8... up-to-date
  en_ZA.UTF-8... done
  en_ZM.UTF-8... done
  en_ZW.UTF-8... done
Generation complete.
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf-2.index...
Run Code Online (Sandbox Code Playgroud)

更新 3.:

在遵循nickguletskii 的建议后,我得到了这个:

$ software-center

(process:22270): Gtk-WARNING **: Locale not supported by C library.
    Using the fallback 'C' locale.
Traceback (most recent call last):
  File "/usr/bin/software-center", line 36, in <module>
    from softwarecenter.utils import (
  File "/usr/share/software-center/softwarecenter/utils.py", line 47, in <module>
    from config import get_config
  File "/usr/share/software-center/softwarecenter/config.py", line 33, in <module>
    class SoftwareCenterConfig(object, SafeConfigParser):
  File "/usr/lib/python2.7/abc.py", line 87, in __new__
    cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace)
TypeError: Error when calling the metaclass bases
    Cannot create a consistent method resolution
order (MRO) for bases SafeConfigParser, object
Run Code Online (Sandbox Code Playgroud)
$ sudo apt-get purge software-center
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo apt-get install software-center
$ sudo dpkg-reconfigure software-center --force
Run Code Online (Sandbox Code Playgroud)
$ sudo apt-get purge software-center
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  software-center-aptdaemon-plugins
Use 'apt-get autoremove' to remove it.
The following packages will be REMOVED:
  software-center*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? Y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 269627 files and directories currently installed.)
Removing software-center ...
Purging configuration files for software-center ...
rmdir: failed to remove `/var/cache/software-center/xapian/': No such file or directory
dpkg: error processing software-center (--purge):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 software-center
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)
$ python --version
Python 2.7.3
Run Code Online (Sandbox Code Playgroud)
$ sudo locale-gen
Generating locales...
  en_US.UTF-8... up-to-date
Generation complete.
Run Code Online (Sandbox Code Playgroud)

看似与语言环境相关的错误消失了,但即使尝试重新安装它,我仍然无法运行 Ubuntu 软件中心。

更新 4.:

重新安装了一些 Python 的东西并更正了 的基类顺序后SoftwareCenterConfig,我得到了这个:

$ sudo apt-get purge software-center
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  python-oneconf software-center-aptdaemon-plugins
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  software-center*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? Y
(Reading database ... 279036 files and directories currently installed.)
Removing software-center ...
Purging configuration files for software-center ...
rmdir: failed to remove ‘/var/cache/software-center/xapian/’: No such file or directory
dpkg: error processing software-center (--purge):
 subprocess installed post-removal script returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 software-center
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

b06*_*b06 2

长话短说:

以下为我修复了它:

sudo chmod -r 755 /usr/local/lib/python2.7/dist-packages/
Run Code Online (Sandbox Code Playgroud)

sudo reboot
Run Code Online (Sandbox Code Playgroud)

我的调试之路

我在 ubuntuone 和软件中心上遇到了同样的问题。以下是我为进一步调试此问题而采取的步骤:

U1_DEBUG=True /usr/lib/ubuntu-sso-client/ubuntu-sso-login
Run Code Online (Sandbox Code Playgroud)

这导致了以下输出:

...
Traceback (most recent call last):
  File "/usr/lib/ubuntu-sso-client/ubuntu-sso-login", line 67, in <module>
    from ubuntu_sso.main import main
  File "/usr/lib/python2.7/dist-packages/ubuntu-sso-client/ubuntu_sso/main/__init__.py", line 39, in <module>
    from twisted.internet import defer
  File "/usr/lib/python2.7/dist-packages/twisted/__init__.py", line 53, in <module>
    _checkRequirements()
  File "/usr/lib/python2.7/dist-packages/twisted/__init__.py", line 40, in _checkRequirements
    raise ImportError(required + ".")
ImportError: Twisted requires zope.interface 3.6.0 or later.
Run Code Online (Sandbox Code Playgroud)

然后我安装了 zope.interface :

sudo easy_install zope.interface
Run Code Online (Sandbox Code Playgroud)

我已经在 python 解释器中尝试过:

>>> import zope.interface
Run Code Online (Sandbox Code Playgroud)

并在 Python 包上遇到一些“权限被拒绝”错误:

IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/EGG-INFO/top_level.txt'IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/EGG-INFO/top_level.txt'
Run Code Online (Sandbox Code Playgroud)

之后我决定更改该文件的访问权限:

sudo chmod -r 755 /usr/local/lib/python2.7/dist-packages/
Run Code Online (Sandbox Code Playgroud)

这导致 Ubuntu One 的 GUI 弹出并尝试同步。仅随后在弹出窗口中收到 dBus 异常。至少 GUI 开始工作了......

对于软件中心,我在终端中运行了以下命令:

software-center --debug
Run Code Online (Sandbox Code Playgroud)

得到了更多相同的 dBus 异常,并在谷歌上搜索了该问题,我发现重新启动足以消除由于超时而触发的异常。


nic*_*kii 0

您的似乎/etc/environment不包含语言设置。您需要将以下行附加到/etc/environment

LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LANGUAGE="en_US:en_US:en"
LANG="en_US.UTF-8"
Run Code Online (Sandbox Code Playgroud)

并重新启动。只是sudo nano /etc/environment、结束、Ctrl + Shift + V、Ctrl + X、Y。