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

Rav*_*shi 4 package-management apt ros 18.04

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

我正在尝试在 Ubuntu 18.04.2 LTS PC 上安装ROS Melodic。不幸的是,命令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).
Run Code Online (Sandbox Code Playgroud)

它建议运行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)
Run Code Online (Sandbox Code Playgroud)

我想运行更新和升级,但遇到了同样的问题。请参阅以下内容:

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).
Run Code Online (Sandbox Code Playgroud)

我也尝试删除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).
Run Code Online (Sandbox Code Playgroud)

我无法继续。我在这里找到了一个可能的解决方法,建议删除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
Run Code Online (Sandbox Code Playgroud)

我现在不知道如何修复它。以下是有关 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
Run Code Online (Sandbox Code Playgroud)

请问有什么解决办法吗?

小智 5

sudo dpkg -r --force-all python-rospkg
Run Code Online (Sandbox Code Playgroud)

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