Ubuntu 从 16.04 升级到 16.10 失败:“无法锁定 /var/cache/apt/archives/lock”

Ubuntu 从 16.04 升级到 16.10 失败:“无法锁定 /var/cache/apt/archives/lock”

我无法将 Ubuntu 从 16.04 升级到 16.10。

错误信息:

Failed to lock /var/cache/apt/archives/lock

关于如何解决这个问题,有很多答案。我尝试了所有。但没有成功。有人能帮忙吗?

关于同一主题的现有帖子:

错误信息:

Calculating the changes    
Calculating the changes
Do you want to start the upgrade?     
10 installed packages are no longer supported by Canonical. You can 
still get support from the community. 
16 packages are going to be removed. 293 new packages are going to be 
installed. 1842 packages are going to be upgraded. 
Installing the upgrade can take several hours. Once the download has 
finished, the process cannot be canceled. 
 Continue [yN]  Details [d]y
Fetching Fetched 0 B in 0s (0 B/s)                                   
Upgrading
Could not download the upgrades 
The upgrade has aborted. Please check your Internet connection or 
installation media and try again. 

Failed to lock /var/cache/apt/archives/lock 

Traceback (most recent call last):   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/yakkety", line 8, in <module>  
File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeMain.py",
line 242, in main   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1880, in run   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1845, in fullUpgrade   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1263, in doDistUpgrade   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1385, in abort   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/sourceslist.py",
line 366, in restore_backup   File "/usr/lib/python3.5/shutil.py",
line 236, in copy
    copymode(src, dst, follow_symlinks=follow_symlinks)   File "/usr/lib/python3.5/shutil.py", line 138, in copymode
    chmod_func(dst, stat.S_IMODE(st.st_mode)) PermissionError: [Errno 1] Operation not permitted: '/etc/apt/sources.list' Error in
sys.excepthook: Traceback (most recent call last):   File
"/usr/lib/python3/dist-packages/apport_python_hook.py", line 109, in
apport_excepthook
    pr.add_proc_info(extraenv=['PYTHONPATH', 'PYTHONHOME'])   File "/usr/lib/python3/dist-packages/apport/report.py", line 544, in
add_proc_info
    self['ExecutableTimestamp'] = str(int(os.stat(self['ExecutablePath']).st_mtime)) PermissionError:
[Errno 13] Permission denied:
'/tmp/ubuntu-release-upgrader-kfjtjdko/yakkety'

Original exception was: Traceback (most recent call last):   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/yakkety", line 8, in <module>  
File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeMain.py",
line 242, in main   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1880, in run   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1845, in fullUpgrade   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1263, in doDistUpgrade   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1385, in abort   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/sourceslist.py",
line 366, in restore_backup   File "/usr/lib/python3.5/shutil.py",
line 236, in copy
    copymode(src, dst, follow_symlinks=follow_symlinks)   File "/usr/lib/python3.5/shutil.py", line 138, in copymode
    chmod_func(dst, stat.S_IMODE(st.st_mode)) PermissionError: 
[Errno 1] Operation not permitted: '/etc/apt/sources.list'

答案1

我遇到了同样的问题,Failed to lock /var/cache/apt/archives/lock每次尝试升级时都会出现。

我按照描述做了一切这里,除了update-manager开始sudo

所以:

  1. sudo apt-get update

  2. sudo apt-get upgrade

  3. sudo apt-get dist-upgrade

  4. sudo update-manager -d

...最终,在第27次尝试时,成功了。

答案2

您做了以下哪一项:

sudo apt-get dist-upgrade
apt-get dist-upgrade?

我几乎敢说您的用户没有正确的权限。如果我不使用 sudo 运行,我会收到类似但更短的输出。

打开终端并输入

groups

你得到的输出是什么?


链接

您发布的链接实际上可能有答案,但并非直接答案。

第三个链接包含另一个链接,其中包含有关如何删除文件锁定的说明解除锁答案

另一个链接指出,任何打开的程序也会接触该文件,这是导致该文件被锁定的原因。您是否确保打开 PC 时默认没有启动更新过程?我会确保您没有启动更新过程,然后重新启动并重试。重新启动将终止该程序,如果它没有自动启动,锁定应该会消失,因此问题应该不会持续存在。

相关内容