Ubuntu – Software Center not Opening at all Error


When I open software from menu, it says "cannot open software database. Please reinstall the software-center package.
When I write software-center on terminal, such error comes:

2014-05-28 09:11:20,584 - softwarecenter.ui.gtk3.app - INFO - setting up proxy 'None'
2014-05-28 09:11:20,593 - softwarecenter.ui.gtk3.app - ERROR - xapian open failed
Traceback (most recent call last):
File "/usr/share/software-center/softwarecenter/ui/gtk3/app.py", line 302, in __init__
if self.db.schema_version() != DB_SCHEMA_VERSION:
File "/usr/share/software-center/softwarecenter/db/database.py", line 289, in schema_version
return self.xapiandb.get_metadata("db-schema-version")
File "/usr/share/software-center/softwarecenter/db/database.py", line 177, in xapiandb
self._db_per_thread[thread_name] = self._get_new_xapiandb()
File "/usr/share/software-center/softwarecenter/db/database.py", line 190, in _get_new_xapiandb
xapiandb = xapian.Database(self._db_pathname)
File "/usr/lib/python2.7/dist-packages/xapian/__init__.py", line 3667, in __init__
DatabaseCorruptError: /var/cache/software-center/xapian/iamchert: Chert version file should be 28 bytes, actually 0

Now, when I write command sudo apt-get remove software-center

dpkg: error: corrupt info database format file '/var/lib/dpkg/info/format'
E: Sub-process /usr/bin/dpkg returned an error code (2)

I had ubuntu before but it kind of got corrupted. Now, I have freshly reinstalled it and even at start, software center is not opening and this error comes.
I hope you have a solution. Thanks.

Best Answer

The cache files are corrupted. To regenerate it open a terminal and enter the following:

sudo rm -r /var/cache/software-center/xapian
sudo mv /var/lib/dpkg/info/format /var/lib/dpkg/info/format.bak
sudo dpkg --clear-avail
sudo apt-get update
sudo apt-get install --reinstall software-center
Related Question