由于依赖问题,无法在 Ubuntu 22.04 上安装 virtualbox

由于依赖问题,无法在 Ubuntu 22.04 上安装 virtualbox

我正在运行 Ubuntu 22.04 并尝试安装 virtualbox。我遇到了依赖性问题,我不确定如何解决。

我尝试了以下方法:

$ sudo apt update && sudo apt upgrade 
$ wget https://www.virtualbox.org/download/oracle_vbox_2016.asc
$ cat oracle_vbox_2016.asc | gpg --dearmor | sudo tee /usr/share/keyrings/virtualbox.gpg > /dev/null 2>&1
$ sudo nano /etc/apt/sources.list.d/virtualbox.list  
### added the following line to the above file
deb [arch=amd64 signed-by=/usr/share/keyrings/virtualbox.gpg] https://download.virtualbox.org/virtualbox/debian jammy contrib
###
$ sudo apt update
$ sudo apt install virtualbox-7.0 

当我运行 sudo apt update 时没有看到任何错误,但是当我尝试安装任何版本的 virtualbox 时,我得到以下输出

$ sudo apt install virtualbox-7.0 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
virtualbox-7.0 is already the newest version (7.0.4-154605~Ubuntu~jammy).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 virtualbox-7.0 : Depends: libqt5help5 (>= 5.15.1) but it is not installable
                  Depends: libqt5opengl5 (>= 5.0.2) but it is not installable
                  Recommends: libsdl-ttf2.0-0 but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

我尝试了前面步骤的多种变体,但结果相同。

我还尝试从下载二进制包https://www.virtualbox.org/wiki/Linux_Downloads对于 Ubuntu 22.04 并安装它:

sudo dpkg -i ./virtualbox-7.0_7.0.4-154605_Ubuntu_jammy_amd64.deb 

然而,这产生了类似的结果:

$ sudo dpkg -i ./virtualbox-7.0_7.0.4-154605_Ubuntu_jammy_amd64.deb 
(Reading database ... 234415 files and directories currently installed.)
Preparing to unpack .../virtualbox-7.0_7.0.4-154605_Ubuntu_jammy_amd64.deb ...
Unpacking virtualbox-7.0 (7.0.4-154605~Ubuntu~jammy) over (7.0.4-154605~Ubuntu~jammy) ...
dpkg: dependency problems prevent configuration of virtualbox-7.0:
 virtualbox-7.0 depends on libqt5help5 (>= 5.15.1); however:
  Package libqt5help5 is not installed.
 virtualbox-7.0 depends on libqt5opengl5 (>= 5.0.2); however:
  Package libqt5opengl5 is not installed.

dpkg: error processing package virtualbox-7.0 (--install):
 dependency problems - leaving unconfigured
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for shared-mime-info (2.1-2) ...
Errors were encountered while processing:
 virtualbox-7.0

有人可以推荐尝试什么吗?

答案1

正如评论中指出的,我需要首先启用Universe存储库

这解决了问题,我能够成功更新和安装 virtualbox 7.0。

答案2

几个月前我发现了以下说明,但我不记得分享它的资源。接下来的步骤帮助我解决了同样的问题:

  1. $ sudo bash -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian eoan contrib" >> /etc/apt/sources.list'
  2. $ wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --dearmor --es --output /usr/share/keyrings/oracle-virtualbox-2016.gpg
  3. $ sudo apt update
  4. $ sudo apt install -y virtualbox-7.0

在这些步骤中,您可能会遇到一些警告,例如:“修复损坏的安装”。请遵循建议和上述步骤。

我希望我的用例有用。

PS Ubuntu 22.04 LTS 用户 :)

相关内容