Ubuntu 20.04安装winehq-stable时出现依赖不满足错误的解决求助
我按照Wine官方教程在Ubuntu 20.04上安装Wine,执行了以下步骤:
- 添加32位架构支持:
sudo dpkg --add-architecture i386 - 下载并添加WineHQ密钥:
sudo wget -nc -O /usr/share/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key - 添加对应Ubuntu 20.04(focal)的源:
sudo wget -nc -P /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/focal/winehq-focal.sources - 更新软件源:
sudo apt update
前面这些步骤都正常执行,但当我尝试安装Wine稳定版时:
sudo apt install --install-recommends winehq-stable
却反复遇到以下错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:The following packages have unmet dependencies:
winehq-stable : Depends: wine-stable (= 8.0.0.0~jammy-1)
E: Unable to correct problems, you have held broken packages.
我已经翻了好多论坛、试了各种方法都没解决,有没有大佬能帮我捋一捋?
给你几个亲测有效的排查修复步骤
我之前也碰到过类似的坑,试试下面这些方法:
先修复系统已有的损坏依赖
先让系统自动处理下可能存在的依赖问题:sudo apt --fix-broken install这个命令会自动尝试补全缺失的依赖、清理损坏的安装包。
检查是否有被锁定的包
错误提示里提到了"held broken packages",先看看哪些包被锁定了:dpkg --get-selections | grep hold如果发现有和Wine相关的锁定包,用下面的命令解锁:
sudo apt-mark unhold [包名]把
[包名]替换成实际查到的锁定包名称就行。确认源和系统版本匹配
你用的是Ubuntu 20.04(focal),但错误里显示依赖的是jammy(Ubuntu 22.04)版本的wine-stable,这大概率是源的问题!
检查下你添加的源文件内容:cat /etc/apt/sources.list.d/winehq-focal.sources如果里面出现了
jammy的字样,手动编辑替换成focal,然后重新更新源:sudo apt update手动指定适配focal的版本安装
先搜索下当前源里可用的wine-stable版本:apt-cache policy wine-stable然后选择适配focal的版本,比如像这样指定版本安装:
sudo apt install --install-recommends wine-stable=[focal对应的版本号] winehq-stable=[focal对应的版本号]改用Ubuntu官方仓库的Wine包
如果上面的方法都不行,不如先删掉第三方的WineHQ源,改用官方仓库的包试试(版本可能不是最新,但兼容性更稳):sudo rm /etc/apt/sources.list.d/winehq-focal.sources sudo rm /usr/share/keyrings/winehq-archive.key sudo apt update sudo apt install wine-stable
备注:内容来源于stack exchange,提问作者Arthur De Backer

