-   Linux - Desktop (
-   -   An unhandled error occured (

jamesubuntufan 03-13-2011 10:05 AM

An unhandled error occured
hi there!

I've been running ubuntu 10.10 on a desktop pc for a few days now. Whenever i try to install something from the software centre i get this message

An unhandled error occured
There seems to be a programming error in aptdaemon, the software that allows you to install/remove software and to perform other package management related tasks. Please report this error at and retry.

Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/aptdaemon/", line 179, in _process_transaction
File "/usr/lib/python2.6/dist-packages/aptdaemon/", line 227, in commit_packages
File "/usr/lib/python2.6/dist-packages/aptdaemon/", line 736, in _commit_changes
File "/usr/lib/python2.6/dist-packages/aptdaemon/", line 518, in _check_obsoleted_dependencies
for pkg in self._cache:
File "/usr/lib/python2.6/dist-packages/apt/", line 173, in __iter__
yield self[pkgname]
File "/usr/lib/python2.6/dist-packages/apt/", line 158, in __getitem__
pkg = self._weakref[key] = Package(self, self._cache[key])
KeyError: 'libfakefs-zuby1.8'

Could somebody please tell me what all this means...i am a newbie to linux and ubuntu so i would greatly appreciate some advice with a resolve to this issue.

Many thanks!

corp769 03-13-2011 10:41 AM


KeyError: 'libfakefs-zuby1.8'
There is no such package. Most likely, that should be ruby1.8 instead of zuby1.8.

Run apt-get clean from the command line and report back if you have any luck. I want to confirm that it is not something simple enough like that. If not, you might have to edit a file or two.


jamesubuntufan 03-13-2011 12:11 PM


Originally Posted by corp769 (Post 4289143)
There is no such package. Most likely, that should be ruby1.8 instead of zuby1.8.


What is interesting, is the fact that i copied and pasted the error directly into this thread, and yet you say there is no such package. what does this mean?

Typing apt-get clean does nothing in the command line, and as i am a complete newbie i assumed that i should use 'sudo' and add the function before putting apt-get clean.

This did nothing visibly in the command line, and the same problem still persists when trying to download the package. What i did earlier today before i encountered this issue; i downloaded gnupg to resolve the issue that gives an error message saying that the package is untrusted or unvarified....does this having something to do with my current issues?

Thanks for getting back so quick, any furthur ideas?

corp769 03-13-2011 12:37 PM

Can you post your /usr/lib/python2.6/dist-packages/apt/ file? I am very curious as to why it is throwing this error.....

jamesubuntufan 03-13-2011 01:32 PM


Originally Posted by corp769 (Post 4289272)
Can you post your /usr/lib/python2.6/dist-packages/apt/ file? I am very curious as to why it is throwing this error.....

sure thing, could you possibly tell me how to do this?

corp769 03-13-2011 01:40 PM


sudo gedit /usr/lib/python2.6/dist-packages/apt/
Copy and paste, and use code tags. If it is a big file though, use

jamesubuntufan 03-14-2011 05:50 AM

change of work and home situation

Originally Posted by corp769 (Post 4289363)

sudo gedit /usr/lib/python2.6/dist-packages/apt/
Copy and paste, and use code tags. If it is a big file though, use

Hi there, before i could carry out your most recent recomendation, my home and work situation has changed dramatically, which means that i will not be able to gain access to my (ubuntu) pc until this next coming sunday.

Thankyou so very much for your assistance with this problem so far, i will carry out your recomendation and post the results at the end of the week. Until then, if you are able to monitor this thread for the next week, when i get back home to continue with the trouble shooting of this problem you should be notified.

Thanks again :)

corp769 03-14-2011 07:47 AM

You just need to make a post, it will come up in my subscribed threads.


jamesubuntufan 03-20-2011 08:01 AM

hi there, i'm back but i only have today to answer questions regarding my system before i become unavailable again for another week.

I entered your command into terminal and password. I got an empty box, when i tried to save that it said "Could not find the file /usr/lib/pyhton2.6/dist-packages/apt/"

any ideas?

corp769 03-20-2011 12:36 PM


Originally Posted by jamesubuntufan (Post 4296910)
hi there, i'm back but i only have today to answer questions regarding my system before i become unavailable again for another week.

I entered your command into terminal and password. I got an empty box, when i tried to save that it said "Could not find the file /usr/lib/pyhton2.6/dist-packages/apt/"

any ideas?

It should be /usr/lib/pyhton2.6/dist-packages/apt/ and not /usr/lib/pyhton2.6/dist-packages/apt/ Note the period at the end.

jamesubuntufan 03-26-2011 09:06 AM

# - apt cache abstraction
# Copyright (c) 2005-2009 Canonical
# Author: Michael Vogt <>
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

import fnmatch
import os
import weakref

import apt_pkg
from apt import Package
from apt_pkg import gettext as _
from apt.deprecation import (AttributeDeprecatedBy, function_deprecated_by,
import apt.progress.text

class FetchCancelledException(IOError):
"""Exception that is thrown when the user cancels a fetch operation."""

class FetchFailedException(IOError):
"""Exception that is thrown when fetching fails."""

class LockFailedException(IOError):
"""Exception that is thrown when locking fails."""

class Cache(object):
"""Dictionary-like package cache.

This class has all the packages that are available in it's

Keyword arguments:
progress -- a OpProgress object
rootdir -- a alternative root directory. if that is given
the system sources.list and system lists/ files are
not read, only files relative to the given rootdir
memonly -- build the cache in memory only

def __init__(self, progress=None, rootdir=None, memonly=False):
self._cache = None
self._depcache = None
self._records = None
self._list = None
self._callbacks = {}
self._weakref = weakref.WeakValueDictionary()
self._set = set()
self._sorted_set = None
if memonly:
# force apt to build its caches in memory
apt_pkg.config.set("Dir::Cache::pkgcache", "")
if rootdir:
if os.path.exists(rootdir+"/etc/apt/apt.conf"):
rootdir + "/etc/apt/apt.conf")
if os.path.isdir(rootdir+"/etc/apt/apt.conf.d"):
rootdir + "/etc/apt/apt.conf.d")
apt_pkg.config.set("Dir", rootdir)
rootdir + "/var/lib/dpkg/status")
# create required dirs/files when run with special rootdir
# automatically
# Call InitSystem so the change to Dir::State::Status is actually
# recognized (LP: #320665)

def _check_and_create_required_dirs(self, rootdir):
check if the required apt directories/files are there and if
not create them
files = ["/var/lib/dpkg/status",
dirs = ["/var/lib/dpkg",
for d in dirs:
if not os.path.exists(rootdir + d):
print "creating: ", rootdir + d
os.makedirs(rootdir + d)
for f in files:
if not os.path.exists(rootdir + f):
open(rootdir + f, "w")

def _run_callbacks(self, name):
""" internal helper to run a callback """
if name in self._callbacks:
for callback in self._callbacks[name]:

def open(self, progress=None):
""" Open the package cache, after that it can be used like
a dictionary
if progress is None:
progress = apt.progress.base.OpProgress()
self.op_progress = progress

self._cache = apt_pkg.Cache(progress)
self._depcache = apt_pkg.DepCache(self._cache)
self._records = apt_pkg.PackageRecords(self._cache)
self._list = apt_pkg.SourceList()
self._sorted_set = None

progress.op = _("Building data structures")
i = last = 0
size = len(self._cache.packages)
for pkg in self._cache.packages:
if progress is not None and last+100 < i:
last = i
# drop stuff with no versions (cruft)
if pkg.has_versions:

i += 1


def __getitem__(self, key):
""" look like a dictionary (get key) """
return self._weakref[key]
except KeyError:
if key in self._set:
key = str(key)
pkg = self._weakref[key] = Package(self, self._cache[key])
return pkg
raise KeyError('The cache has no package named %r' % key)

def __iter__(self):
# We iterate sorted over package names here. With this we read the
# package lists linearly if we need to access the package records,
# instead of having to do thousands of random seeks; the latter
# is disastrous if we use compressed package indexes, and slower than
# necessary for uncompressed indexes.
if self._sorted_set is None:
self._sorted_set = sorted(self._set)

for pkgname in self._sorted_set:
yield self[pkgname]
raise StopIteration

def has_key(self, key):
return (key in self._set)

def __contains__(self, key):
return (key in self._set)

def __len__(self):
return len(self._set)

def keys(self):
return list(self._set)

def get_changes(self):
""" Get the marked changes """
changes = []
marked_keep = self._depcache.marked_keep
for pkg in self._cache.packages:
if not marked_keep(pkg):
except KeyError:
package = self._weakref[] = Package(self, pkg)
return changes

def upgrade(self, dist_upgrade=False):
"""Upgrade all packages.

If the parameter *dist_upgrade* is True, new dependencies will be
installed as well (and conflicting packages may be removed). The
default value is False.

def required_download(self):
"""Get the size of the packages that are required to download."""
pm = apt_pkg.PackageManager(self._depcache)
fetcher = apt_pkg.Acquire()
pm.get_archives(fetcher, self._list, self._records)
return fetcher.fetch_needed

def required_space(self):
"""Get the size of the additional required space on the fs."""
return self._depcache.usr_size

def req_reinstall_pkgs(self):
"""Return the packages not downloadable packages in reqreinst state."""
reqreinst = set()
get_candidate_ver = self._depcache.get_candidate_ver
states = frozenset((apt_pkg.INSTSTATE_REINSTREQ,
for pkg in self._cache.packages:
cand = get_candidate_ver(pkg)
if cand and not cand.downloadable and pkg.inst_state in states:
return reqreinst

def _run_fetcher(self, fetcher):
# do the actual fetching
res =

# now check the result (this is the code from
failed = False
transient = False
err_msg = ""
for item in fetcher.items:
if item.status == item.STAT_DONE:
if item.STAT_IDLE:
transient = True
err_msg += "Failed to fetch %s %s\n" % (item.desc_uri,
failed = True

# we raise a exception if the download failed or it was cancelt
if res == fetcher.RESULT_CANCELLED:
raise FetchCancelledException(err_msg)
elif failed:
raise FetchFailedException(err_msg)
return res

def _fetch_archives(self, fetcher, pm):
""" fetch the needed archives """

# get lock
lockfile = apt_pkg.config.find_dir("Dir::Cache::Archives") + "lock"
lock = apt_pkg.get_lock(lockfile)
if lock < 0:
raise LockFailedException("Failed to lock %s" % lockfile)

# this may as well throw a SystemError exception
if not pm.get_archives(fetcher, self._list, self._records):
return False
# now run the fetcher, throw exception if something fails to be
# fetched
return self._run_fetcher(fetcher)

def is_virtual_package(self, pkgname):
"""Return whether the package is a virtual package."""
pkg = self._cache[pkgname]
except KeyError:
return False
return bool(pkg.has_provides and not pkg.has_versions)

def get_providing_packages(self, pkgname, candidate_only=True,
"""Return a list of all packages providing a package.

Return a list of packages which provide the virtual package of the
specified name.

If 'candidate_only' is False, return all packages with at
least one version providing the virtual package. Otherwise,
return only those packages where the candidate version
provides the virtual package.

If 'include_nonvirtual' is True then it will search for all
packages providing pkgname, even if pkgname is not itself
a virtual pkg.

providers = set()
get_candidate_ver = self._depcache.get_candidate_ver
vp = self._cache[pkgname]
if vp.has_versions and not include_nonvirtual:
return list(providers)
except KeyError:
return list(providers)

for provides, providesver, version in vp.provides_list:
pkg = version.parent_pkg
if not candidate_only or (version == get_candidate_ver(pkg)):
except KeyError:
package = self._weakref[] = Package(self, pkg)
return list(providers)

def update(self, fetch_progress=None, pulse_interval=0,
raise_on_error=True, sources_list=None):
"""Run the equivalent of apt-get update.

The first parameter *fetch_progress* may be set to an instance of
apt.progress.FetchProgress, the default is apt.progress.FetchProgress()
sources_list -- Update a alternative sources.list than the default.
Note that the sources.list.d directory is ignored in this case
lockfile = apt_pkg.config.find_dir("Dir::State::Lists") + "lock"
lock = apt_pkg.get_lock(lockfile)

if lock < 0:
raise LockFailedException("Failed to lock %s" % lockfile)

if sources_list:
old_sources_list = apt_pkg.config.find("Dir::Etc::sourcelist")
old_sources_list_d = apt_pkg.config.find("Dir::Etc::sourceparts")
old_cleanup = apt_pkg.config.find("APT::List-Cleanup")
apt_pkg.config.set("Dir::Etc::sourcelist", os.path.abspath(sources_list))
apt_pkg.config.set("Dir::Etc::sourceparts", "xxx")
apt_pkg.config.set("APT::List-Cleanup", "0")
slist = apt_pkg.SourceList()
slist = self._list

if fetch_progress is None:
fetch_progress = apt.progress.base.AcquireProgress()
res = self._cache.update(fetch_progress, slist,
except SystemError, e:
raise FetchFailedException(e)
if not res and raise_on_error:
raise FetchFailedException()
return res
if sources_list:
apt_pkg.config.set("Dir::Etc::sourcelist", old_sources_list)
apt_pkg.config.set("Dir::Etc::sourceparts", old_sources_list_d)
apt_pkg.config.set("APT::List-Cleanup", old_cleanup)

def install_archives(self, pm, install_progress):
The first parameter *pm* refers to an object returned by

The second parameter *install_progress* refers to an InstallProgress()
object of the module apt.progress.
# compat with older API
except AttributeError:
res =
except AttributeError:
return res

def commit(self, fetch_progress=None, install_progress=None):
"""Apply the marked changes to the cache.

The first parameter, *fetch_progress*, refers to a FetchProgress()
object as found in apt.progress, the default being

The second parameter, *install_progress*, is a
apt.progress.InstallProgress() object.
# use the new acquire/pkgmanager interface here,
# raise exceptions when a download or install fails
# and send proper error strings to the application.
# Current a failed download will just display "error"
# which is less than optimal!

if fetch_progress is None:
fetch_progress = apt.progress.base.AcquireProgress()
if install_progress is None:
install_progress = apt.progress.base.InstallProgress()

pm = apt_pkg.PackageManager(self._depcache)
fetcher = apt_pkg.Acquire(fetch_progress)
while True:
# fetch archives first
res = self._fetch_archives(fetcher, pm)

# then install
res = self.install_archives(pm, install_progress)
if res == pm.RESULT_COMPLETED:
elif res == pm.RESULT_FAILED:
raise SystemError("installArchives() failed")
elif res == pm.RESULT_INCOMPLETE:
raise SystemError("internal-error: unknown result code "
"from InstallArchives: %s" % res)
# reload the fetcher for media swaping
return (res == pm.RESULT_COMPLETED)

def clear(self):
""" Unmark all changes """

# cache changes

def cache_post_change(self):
" called internally if the cache has changed, emit a signal then "

def cache_pre_change(self):
""" called internally if the cache is about to change, emit
a signal then """

def connect(self, name, callback):
""" connect to a signal, currently only used for
cache_{post,pre}_{changed,open} """
if not name in self._callbacks:
self._callbacks[name] = []

def actiongroup(self):
"""Return an ActionGroup() object for the current cache.

Action groups can be used to speedup actions. The action group is
active as soon as it is created, and disabled when the object is
deleted or when release() is called.

You can use the action group as a context manager, this is the
recommended way::

with cache.actiongroup():
for package in my_selected_packages:

This way, the ActionGroup is automatically released as soon as the
with statement block is left. It also has the benefit of making it
clear which parts of the code run with a action group and which
return apt_pkg.ActionGroup(self._depcache)

def dpkg_journal_dirty(self):
"""Return True if the dpkg was interrupted

All dpkg operations will fail until this is fixed, the action to
fix the system if dpkg got interrupted is to run
'dpkg --configure -a' as root.
dpkg_status_dir = os.path.dirname(
for f in os.listdir(os.path.join(dpkg_status_dir, "updates")):
if fnmatch.fnmatch(f, "[0-9]*"):
return True
return False

def broken_count(self):
"""Return the number of packages with broken dependencies."""
return self._depcache.broken_count

def delete_count(self):
"""Return the number of packages marked for deletion."""
return self._depcache.del_count

def install_count(self):
"""Return the number of packages marked for installation."""
return self._depcache.inst_count

def keep_count(self):
"""Return the number of packages marked as keep."""
return self._depcache.keep_count

if apt_pkg._COMPAT_0_7:
_runCallbacks = function_deprecated_by(_run_callbacks)
getChanges = function_deprecated_by(get_changes)
requiredDownload = AttributeDeprecatedBy('required_download')
additionalRequiredSpace = AttributeDeprecatedBy('required_space')
reqReinstallPkgs = AttributeDeprecatedBy('req_reinstall_pkgs')
_runFetcher = function_deprecated_by(_run_fetcher)
_fetchArchives = function_deprecated_by(_fetch_archives)
isVirtualPackage = function_deprecated_by(is_virtual_package)
getProvidingPackages = function_deprecated_by(get_providing_packages)
installArchives = function_deprecated_by(install_archives)
cachePostChange = function_deprecated_by(cache_post_change)
cachePreChange = function_deprecated_by(cache_pre_change)

class ProblemResolver(object):
"""Resolve problems due to dependencies and conflicts.

The first argument 'cache' is an instance of apt.Cache.

def __init__(self, cache):
self._resolver = apt_pkg.ProblemResolver(cache._depcache)

def clear(self, package):
"""Reset the package to the default state."""

def install_protect(self):
"""mark protected packages for install or removal."""

def protect(self, package):
"""Protect a package so it won't be removed."""

def remove(self, package):
"""Mark a package for removal."""

def resolve(self):
"""Resolve dependencies, try to remove packages where needed."""

def resolve_by_keep(self):
"""Resolve dependencies, do not try to remove packages."""

# ----------------------------- experimental interface

class Filter(object):
""" Filter base class """

def apply(self, pkg):
""" Filter function, return True if the package matchs a
filter criteria and False otherwise
return True

class MarkedChangesFilter(Filter):
""" Filter that returns all marked changes """

def apply(self, pkg):
if pkg.marked_install or pkg.marked_delete or pkg.marked_upgrade:
return True
return False

class FilteredCache(object):
""" A package cache that is filtered.

Can work on a existing cache or create a new one

def __init__(self, cache=None, progress=None):
if cache is None:
self.cache = Cache(progress)
self.cache = cache
self.cache.connect("cache_post_change", self.filter_cache_post_change)
self.cache.connect("cache_post_open", self.filter_cache_post_change)
self._filtered = {}
self._filters = []

def __len__(self):
return len(self._filtered)

def __getitem__(self, key):
return self.cache[key]

def __iter__(self):
for pkgname in self._filtered:
yield self.cache[pkgname]

def keys(self):
return self._filtered.keys()

def has_key(self, key):
return (key in self._filtered)

def __contains__(self, key):
return (key in self._filtered)

def _reapply_filter(self):
" internal helper to refilter "
self._filtered = {}
for pkg in self.cache:
for f in self._filters:
if f.apply(pkg):
self._filtered[] = 1

def set_filter(self, filter):
"""Set the current active filter."""
self._filters = []
# force a cache-change event that will result in a refiltering

def filter_cache_post_change(self):
"""Called internally if the cache changes, emit a signal then."""
#print "filterCachePostChange()"

# def connect(self, name, callback):
# self.cache.connect(name, callback)

def __getattr__(self, key):
"""we try to look exactly like a real cache."""
#print "getattr: %s " % key
return getattr(self.cache, key)

if apt_pkg._COMPAT_0_7:
_reapplyFilter = function_deprecated_by(_reapply_filter)
setFilter = function_deprecated_by(set_filter)
filterCachePostChange = function_deprecated_by(\

def cache_pre_changed():
print "cache pre changed"

def cache_post_changed():
print "cache post changed"

def _test():
"""Internal test code."""
print "Cache self test"
cache = Cache(apt.progress.text.OpProgress())
cache.connect("cache_pre_change", cache_pre_changed)
cache.connect("cache_post_change", cache_post_changed)
print ("aptitude" in cache)
pkg = cache["aptitude"]
print len(cache)

for pkgname in cache.keys():
assert cache[pkgname].name == pkgname

changes = cache.get_changes()
print len(changes)
for pkg in changes:

# see if fetching works
for dirname in ["/tmp/pytest", "/tmp/pytest/partial"]:
if not os.path.exists(dirname):
apt_pkg.config.set("Dir::Cache::Archives", "/tmp/pytest")
pm = apt_pkg.PackageManager(cache._depcache)
fetcher = apt_pkg.Acquire(apt.progress.text.AcquireProgress())
cache._fetch_archives(fetcher, pm)

print "Testing filtered cache (argument is old cache)"
filtered = FilteredCache(cache)
filtered.cache.connect("cache_pre_change", cache_pre_changed)
filtered.cache.connect("cache_post_change", cache_post_changed)
print len(filtered)
for pkgname in filtered.keys():
assert pkgname == filtered[pkg].name

print len(filtered)

print "Testing filtered cache (no argument)"
filtered = FilteredCache(progress=apt.progress.base.OpProgress())
filtered.cache.connect("cache_pre_change", cache_pre_changed)
filtered.cache.connect("cache_post_change", cache_post_changed)
print len(filtered)
for pkgname in filtered.keys():
assert pkgname == filtered[pkgname].name

print len(filtered)
if __name__ == '__main__':

jamesubuntufan 03-26-2011 09:42 AM

In addition to the information above, i thought this might come in useful. (i got this with the usual error message in the details section when trying to install skype)

Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/aptdaemon/", line 779, in simulate
return self._simulate_helper(trans, status_path)
File "/usr/lib/python2.6/dist-packages/aptdaemon/", line 861, in _simulate_helper
File "/usr/lib/python2.6/dist-packages/apt/", line 57, in __init__
File "/usr/lib/python2.6/dist-packages/apt/", line 66, in open
self._debfile = apt_inst.DebFile(open(self.filename))
IOError: [Errno 2] No such file or directory: '/tmp/skype-ubuntu-intrepid_2.1.0.81-1_i386.deb'

corp769 03-26-2011 02:11 PM

Can you please edit your posts and use code tags? Thanks.

corp769 03-26-2011 02:13 PM

And try running apt-get clean all, and try installing again.

jamesubuntufan 03-27-2011 12:03 PM


Originally Posted by corp769 (Post 4304436)
And try running apt-get clean all, and try installing again.

This has solved the problem, thankyou very much!

for future reference, how do i use code tags?

Many thanks,

All times are GMT -5. The time now is 12:24 PM.