在 Ubuntu 18.04 LTS 上安装 ROS Melodic 时,由于“apt --fix-broken install”无效而陷入循环

在 Ubuntu 18.04 LTS 上安装 ROS Melodic 时,由于“apt --fix-broken install”无效而陷入循环

这个问题可能完全和 ROS 有关,但是目前我还不确定错误来源。因此我在这个大社区中发布了它。

我正在尝试安装ROS旋律在 Ubuntu 18.04.2 LTS PC 上。不幸的是,命令sudo apt install ros-melodic-desktop-full失败了。以下是再次运行同一命令时的输出:

ravi@lab:~$ sudo apt install ros-melodic-desktop-full
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ros-melodic-desktop-full is already the newest version (1.4.1-0bionic.20190204.220757).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 python-rosdistro-modules : Depends: python-rospkg-modules but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

它建议运行apt --fix-broken install,我照做了,但并没有解决问题。见下文:

ravi@lab:~$ sudo apt  --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libllvm6.0:i386 python-genmsg python-genpy python-roscpp-msgs python-rosgraph python-rosgraph-msgs python-std-msgs x11proto-dri2-dev x11proto-gl-dev
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  python-rospkg-modules
The following NEW packages will be installed:
  python-rospkg-modules
0 upgraded, 1 newly installed, 0 to remove and 53 not upgraded.
461 not fully installed or removed.
Need to get 0 B/23.4 kB of archives.
After this operation, 133 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 542662 files and directories currently installed.)
Preparing to unpack .../python-rospkg-modules_1.1.7-1_all.deb ...
Unpacking python-rospkg-modules (1.1.7-1) ...
dpkg: error processing archive /var/cache/apt/archives/python-rospkg-modules_1.1.7-1_all.deb (--unpack):
 trying to overwrite '/usr/lib/python2.7/dist-packages/rospkg/manifest.py', which is also in package python-rospkg 1.1.4-1
Errors were encountered while processing:
 /var/cache/apt/archives/python-rospkg-modules_1.1.7-1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我想过运行更新和升级,但遇到了同样的问题。请参见下文:

ravi@lab:~$ sudo apt update
Hit:1 http://ny-mirrors.evowise.com/ubuntu bionic InRelease
Hit:2 http://linux.teamviewer.com/deb stable InRelease                                                                                                           
Hit:3 http://ny-mirrors.evowise.com/ubuntu bionic-updates InRelease                                                                                              
Hit:4 http://ny-mirrors.evowise.com/ubuntu bionic-backports InRelease                                                                      
Hit:5 http://ny-mirrors.evowise.com/ubuntu bionic-security InRelease                                                 
Ign:6 http://dl.google.com/linux/chrome/deb stable InRelease                                                         
Hit:7 http://dl.google.com/linux/chrome/deb stable Release                                                                     
Hit:8 http://packages.ros.org/ros/ubuntu bionic InRelease                                                                      
Hit:10 http://ppa.launchpad.net/danielrichter2007/grub-customizer/ubuntu bionic InRelease                              
Hit:12 http://ppa.launchpad.net/gezakovacs/ppa/ubuntu bionic InRelease                              
Hit:11 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease                       
Hit:13 http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu bionic InRelease
Reading package lists... Done 
Building dependency tree       
Reading state information... Done
53 packages can be upgraded. Run 'apt list --upgradable' to see them.
ravi@lab:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 python-rosdistro-modules : Depends: python-rospkg-modules but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

我也尝试删除该ros-melodic-desktop-full包但是徒劳无功,如下所示:

ravi@lab:~$ sudo apt purge --remove ros-melodic-desktop-full
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 python-rosdistro-modules : Depends: python-rospkg-modules but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

我无法继续。我找到了一个可能的解决方法这里建议删除python-rospkg软件包,但也没有用。请参见下文:

ravi@lab:~$ sudo dpkg -P python-rospkg
[sudo] password for ravi: 
dpkg: dependency problems prevent removal of python-rospkg:
 ros-melodic-roscreate depends on python-rospkg.
 ros-melodic-rosunit depends on python-rospkg.
 ros-melodic-roslaunch depends on python-rospkg (>= 1.0.37); however:
  Package python-rospkg is to be removed.
 ros-melodic-rosgraph depends on python-rospkg; however:
  Package python-rospkg is to be removed.
 ros-melodic-rosbag depends on python-rospkg; however:
  Package python-rospkg is to be removed.
 ros-melodic-rqt-robot-steering depends on python-rospkg.
 ros-melodic-roslib depends on python-rospkg (>= 1.0.37).
 ros-melodic-rqt-pose-view depends on python-rospkg; however:
  Package python-rospkg is to be removed.
 ros-melodic-qt-gui-py-common depends on python-rospkg.
 python-rosdep depends on python-rospkg (>= 1.0.37); however:
  Package python-rospkg is to be removed.
 ros-melodic-rqt-publisher depends on python-rospkg.
 ros-melodic-rqt-console depends on python-rospkg.
 ros-melodic-rosmake depends on python-rospkg.
 ros-melodic-rqt-plot depends on python-rospkg.
 ros-melodic-qt-gui depends on python-rospkg.
 ros-melodic-rqt-msg depends on python-rospkg.
 ros-melodic-rosclean depends on python-rospkg.
 ros-melodic-roswtf depends on python-rospkg; however:
  Package python-rospkg is to be removed.
 ros-melodic-rospy depends on python-rospkg.
 ros-melodic-rqt-graph depends on python-rospkg.
 ros-melodic-rqt-robot-monitor depends on python-rospkg.
 ros-melodic-rqt-service-caller depends on python-rospkg.
 ros-melodic-rqt-runtime-monitor depends on python-rospkg.
 ros-melodic-rqt-py-console depends on python-rospkg.
 ros-melodic-resource-retriever depends on python-rospkg; however:
  Package python-rospkg is to be removed.
 ros-melodic-rqt-dep depends on python-rospkg.
 ros-melodic-rqt-tf-tree depends on python-rospkg.
 ros-melodic-rosmsg depends on python-rospkg.
 ros-melodic-rqt-web depends on python-rospkg.
 ros-melodic-rqt-bag depends on python-rospkg.
 ros-melodic-rqt-shell depends on python-rospkg.
 ros-melodic-rqt-topic depends on python-rospkg.
 ros-melodic-rqt-logger-level depends on python-rospkg.

dpkg: error processing package python-rospkg (--purge):
 dependency problems - not removing
Errors were encountered while processing:
 python-rospkg

我现在不知道该如何修复它。以下是有关 PC 的更多信息:

ravi@lab:~$ python --version
Python 2.7.15rc1

ravi@lab:~$ uname -a
Linux lab 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
ravi@lab:~$ cat /etc/issue
Ubuntu 18.04.2 LTS \n \l

请问有什么解决方法吗?

答案1

sudo dpkg -r --force-all python-rospkg

之后,sudo apt --fix-broken install 如果你想重新安装 ros,请运行sudo apt-get remove ros-*删除 ros。然后从安装 ROShttps://wiki.ros.org/ROS/Installation

答案2

我遇到了同样的问题,并编写了一个脚本来删除 ros 安装包。我不得不多次运行它,直到没有输出。

以下是脚本

import os
import sys
import re

data = sys.stdin.read()
lines = data.split('\n')

pkgPat = " [a-zA-Z0-9\-]* : Depends: .*"
pkgNamePat = " [a-zA-Z0-9\-]* :"

relLines = []
for line in lines:
    if(re.match(pkgPat, line) is not None):
        relLines.append(line)

for line in relLines:
    pkg = re.search(pkgNamePat, line)[0][1:-2]
    if pkg is not None:
        os.system('sudo dpkg -r --force-all ' + pkg)
    else:
        print("None: " + line)

多次运行直到没有输出(脚本名为fixros.py:

sudo apt-get autoremove | fixros.py

答案3

我遇到了同样的问题,这是由于包损坏导致的,提示建议您运行apt --fix-broken install,但它返回:

E: Sub-process /usr/bin/dpkg returned an error code (1)

还列出了一些“.deb”文件无法覆盖。您可以通过运行来修复此问题

sudo dpkg -i --force-overwrite [packaage full path]

在这种情况下,它将是:

sudo dpkg -i --force-overwrite  /var/cache/apt/archives/python-rospkg-modules_1.1.7-1_all.deb

它解决了所有错误。如果它对你也有用,请告诉我!

答案4

做就是了 :

sudo dpkg -P --force-all PACKAGETOREMOVE
sudo apt --fix-broken install
sudo apt-get clean
sudo apt-get autoremove

相关内容