当我尝试从 16.04 升级到 16.10 并打开回溯时收到一条错误消息:
unattended_upgrade 因 apt.cache.LockFailedException in_fetch_archives() 而崩溃:
无法锁定 /var/cache/apt/archives/lock
我发现它链接到一个名为的python文件unattended_upgrade
。它引用了一个名为的文件cache.py
,回溯表明它在第338行不起作用,我发现是这样的:
# 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)
try:
# 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)
finally:
os.close(lock)
此代码是 Python 3 的,我不知道它有什么用处,也不知道该如何修复,但它不允许我升级。提前致谢
答案1
尝试
sudo rm -f /var/cache/apt/archives/lock
sudo apt-get -f -y remove
sudo apt-get -f -y update
我不确定我是否正确记住了这些命令,所以尝试一下。