如何解除安裝 VirtualBox 6.1.x 的 VirtualBox 7.0.x?

如何解除安裝 VirtualBox 6.1.x 的 VirtualBox 7.0.x?

在 Ubuntu Desktop 22.04 上執行:

sudo dpkg -i virtualbox-7.0_7.0.4-154605~Ubuntu~jammy_amd64.deb 

但透過解包過程被通過ctrl+取消c。因為需要 6.1.40 版本。幾秒鐘後被處決

sudo dpkg -i virtualbox-6.1_6.1.40-154048~Ubuntu~jammy_amd64.deb 

並展示

(Reading database ... 200469 files and directories currently installed.)
Preparing to unpack virtualbox-6.1_6.1.40-154048~Ubuntu~jammy_amd64.deb ...
Unpacking virtualbox-6.1 (6.1.40-154048~Ubuntu~jammy) over (6.1.40-154048~Ubuntu~jammy) ...
dpkg: dependency problems prevent configuration of virtualbox-6.1:
 virtualbox-6.1 depends on libqt5core5a (>= 5.15.1); however:
  Package libqt5core5a is not installed.
 virtualbox-6.1 depends on libqt5gui5 (>= 5.14.1) | libqt5gui5-gles (>= 5.14.1); however:
  Package libqt5gui5 is not installed.
  Package libqt5gui5-gles is not installed.
 virtualbox-6.1 depends on libqt5opengl5 (>= 5.0.2); however:
  Package libqt5opengl5 is not installed.
 virtualbox-6.1 depends on libqt5printsupport5 (>= 5.0.2); however:
  Package libqt5printsupport5 is not installed.
 virtualbox-6.1 depends on libqt5widgets5 (>= 5.15.1); however:
  Package libqt5widgets5 is not installed.
 virtualbox-6.1 depends on libqt5x11extras5 (>= 5.6.0); however:
  Package libqt5x11extras5 is not installed.
 virtualbox-6.1 depends on libsdl1.2debian (>= 1.2.11); however:
  Package libsdl1.2debian is not installed.

dpkg: error processing package virtualbox-6.1 (--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-6.1

因此被執行sudo apt -f install並顯示

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: The package virtualbox-7.0 needs to be reinstalled, but I can't find an archive for it.

sudo apt purge virtualbox-7.0表演

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: The package virtualbox-7.0 needs to be reinstalled, but I can't find an archive for it.

如果我稍後嘗試重新安裝 VB 7 以清除它

sudo apt install ./virtualbox-7.0_7.0.4-154605~Ubuntu~jammy_amd64.deb 

表明

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 virtualbox-6.1 : Depends: libqt5core5a (>= 5.15.1) but it is not installed
                  Depends: libqt5gui5 (>= 5.14.1) but it is not installed or
                           libqt5gui5-gles (>= 5.14.1) but it is not installed
                  Depends: libqt5opengl5 (>= 5.0.2) but it is not installed
                  Depends: libqt5printsupport5 (>= 5.0.2) but it is not installed
                  Depends: libqt5widgets5 (>= 5.15.1) but it is not installed
                  Depends: libqt5x11extras5 (>= 5.6.0) but it is not installed
                  Depends: libsdl1.2debian (>= 1.2.11)
                  Recommends: libsdl-ttf2.0-0 but it is not installed
                  Recommends: gcc but it is not installed
                  Recommends: make or
                              build-essential but it is not installed or
                              dpkg-dev but it is not installed
                  Recommends: binutils but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

如果執行則apt --fix-broken install顯示

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: The package virtualbox-7.0 needs to be reinstalled, but I can't find an archive for it.

如果我想重新安裝 VB 6.1

sudo apt install ./virtualbox-6.1_6.1.40-154048~Ubuntu~jammy_amd64.deb 

它顯示(觀察它的劇照參考7)

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: The package virtualbox-7.0 needs to be reinstalled, but I can't find an archive for it.

如果我想卸載 VB 6.1,sudo apt purge virtualbox-6.1它會顯示

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: The package virtualbox-7.0 needs to be reinstalled, but I can't find an archive for it.

如何解決這個問題?

目標是完全卸載VB 7並安裝VB 6.1。

Α

根據用戶535733的建議,如果執行命令:

sudo dpkg -i virtualbox-7.0_7.0.4-154605~Ubuntu~jammy_amd64.deb 

出現

dpkg: regarding virtualbox-7.0_7.0.4-154605~Ubuntu~jammy_amd64.deb containing virtualbox-7.0:
 virtualbox-7.0 conflicts with virtualbox
  virtualbox-6.1 provides virtualbox and is present and unpacked but not configured.

dpkg: error processing archive virtualbox-7.0_7.0.4-154605~Ubuntu~jammy_amd64.deb (--install):
 conflicting packages - not installing virtualbox-7.0
Errors were encountered while processing:
 virtualbox-7.0_7.0.4-154605~Ubuntu~jammy_amd64.deb

答案1

我找到了一個關於使用命令的可能解決方案:

sudo dpkg --remove --force-remove-reinstreq <packagename>

它符合帖子和解決方案:

但它的第一條評論表明:

This command should always be avoided as it breaks you system more than it repairs

不確定這是否屬實。但也是有風險的

解決方案

因此我做了以下工作並最終成功:

sudo cp /var/lib/dpkg/status status.bkp
sudo gedit /var/lib/dpkg/status

刪除包含錯誤訊息的部分。就我而言是:

Package: virtualbox-7.0
Status: install reinstreq half-installed
Priority: optional
Section: contrib/misc
Architecture: amd64
Version: 7.0.4-154605~Ubuntu~jammy

觀察status-安裝reinstreq 半安裝

這個解決方案的來源/歸功於這篇文章

因此命令工作正常

sudo dpkg -i virtualbox-6.1_6.1.40-154048~Ubuntu~jammy_amd64.deb
sudo apt -f install

關於 VirtualBox7使用以下命令會發生:

sudo apt remove virtualbox-7
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package virtualbox-7

sudo apt remove virtualbox-7.0
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'virtualbox-7.0' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

sudo apt purge virtualbox-7.0
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'virtualbox-7.0' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

所以看起來一切都好。

相關內容