我尝试从 Ubuntu 16.04 升级到 Ubuntu 18.04 并遇到以下错误:
Failed to lock /var/cache/apt/archives/lock
我在 google/askubuntu/ubuntu subreddits 上搜索了以前的故障排除步骤,但到目前为止一切都失败了(首先,在 Ask Ubuntu 上,这个线程导致了很多不同的解决方案不幸的是,这并没有起作用。
有人在从 16.04 升级到 18.04 时遇到过这个问题并且能够解决吗?
运行系统升级程序后的输出如下:
Fetching
Could not download the upgrades
The upgrade has aborted. Please check your Internet connection or
installation media and try again. All files downloaded so far have
been kept.
Failed to lock /var/cache/apt/archives/lock
Traceback (most recent call last):
File "/tmp/ubuntu-release-upgrader-6o5gq951/bionic", line 8, in <module>
File "/tmp/ubuntu-release-upgrader-6o5gq951/DistUpgrade/DistUpgradeMain.py", line 238, in main
File "/tmp/ubuntu-release-upgrader-6o5gq951/DistUpgrade/DistUpgradeController.py", line 1949, in run
File "/tmp/ubuntu-release-upgrader-6o5gq951/DistUpgrade/DistUpgradeController.py", line 1905, in fullUpgrade
File "/tmp/ubuntu-release-upgrader-6o5gq951/DistUpgrade/DistUpgradeController.py", line 1201, in doDistUpgradeFetching
File "/tmp/ubuntu-release-upgrader-6o5gq951/DistUpgrade/DistUpgradeController.py", line 1450, in abort
File "/tmp/ubuntu-release-upgrader-6o5gq951/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-6o5gq951/bionic'
Original exception was:
Traceback (most recent call last):
File "/tmp/ubuntu-release-upgrader-6o5gq951/bionic", line 8, in <module>
File "/tmp/ubuntu-release-upgrader-6o5gq951/DistUpgrade/DistUpgradeMain.py", line 238, in main
File "/tmp/ubuntu-release-upgrader-6o5gq951/DistUpgrade/DistUpgradeController.py", line 1949, in run
File "/tmp/ubuntu-release-upgrader-6o5gq951/DistUpgrade/DistUpgradeController.py", line 1905, in fullUpgrade
File "/tmp/ubuntu-release-upgrader-6o5gq951/DistUpgrade/DistUpgradeController.py", line 1201, in doDistUpgradeFetching
File "/tmp/ubuntu-release-upgrader-6o5gq951/DistUpgrade/DistUpgradeController.py", line 1450, in abort
File "/tmp/ubuntu-release-upgrader-6o5gq951/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
您的错误完全匹配此错误报告这个漏洞在 2016 年(16.04 到 16.10 升级时)被标记为严重,但显然从未得到解决。
报告您的发现,让错误报告从休眠状态中恢复过来。它似乎影响了很多人(正如 AskUbuntu 上的几个问题所证实的那样)。
好处是错误报告提出了一些解决方法。
我怀疑该错误可能是由发行版外的 Python 软件包安装引起的。您是否从源代码或 PPA 安装了任何 Python 版本?如果是,请撤消该操作,然后重试升级。