【工程师分享】Ubuntu18.04安装ROS时,遇到错误“unmet dependencies. Unable to correct problems, you have held broken packages."

作者:HankFu,博客园

问题
Ubuntu18.04安装ROS ros-melodic-desktop-full时,遇到错误“unmet dependencies. Unable to correct problems, you have held broken packages."。

根据提示,逐层安装缺失的模块,包括ros-melodic-perception, ros-melodic-perception-pcl, ros-melodic-pcl-conversions, libpcl-dev, libvtk6-dev, libvtk6-qt-dev, libvtk6-java, 一直报告同样错误。

最后在安装libvtk6-jni时,Ubuntu18.04系统提示卸载libvtk7-dev, libvtk7-java, libvtk7-jni; 并安装 libvtk6-jni, libvtk6.3-qt。

然后再安装ros-melodic-perception和ros-melodic-desktop-full,能够成功安装。

安装ROS的命令

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update

sudo apt install ros-melodic-desktop-full

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo rosdep init
rosdep update

mkdir -p ./catkin_ws/src
cd ./catkin_ws/src
catkin_init_workspace
cd ../
catkin_make
source ./catkin_ws/devel/setup.bash

命令记录

/proj/hankf/slam/$ sudo apt install ros-melodic-desktop-full
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:
ros-melodic-desktop-full : Depends: ros-melodic-perception but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

/proj/hankf/slam/$ sudo apt install ros-melodic-perception
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:
ros-melodic-perception : Depends: ros-melodic-perception-pcl but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

/proj/hankf/slam/$ sudo apt install ros-melodic-perception-pcl
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:
ros-melodic-perception-pcl : Depends: ros-melodic-pcl-conversions but it is not going to be installed
Depends: ros-melodic-pcl-ros but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

/proj/hankf/slam/$ sudo apt install ros-melodic-pcl-conversions
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:
ros-melodic-pcl-conversions : Depends: libpcl-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

/proj/hankf/slam/$ sudo apt install libpcl-dev
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:
libpcl-dev : Depends: libvtk6-dev but it is not going to be installed
Depends: libvtk6-qt-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

/proj/hankf/slam/$ sudo apt install libvtk6-dev
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:
libvtk6-dev : Depends: libvtk6-java (= 6.3.0+dfsg1-11build1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

/proj/hankf/slam/$ sudo apt install libvtk6-java
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:
libvtk6-java : Depends: libvtk6-jni (= 6.3.0+dfsg1-11build1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

/proj/hankf/slam/$ sudo apt install libvtk6-jni
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
cython3 libgl2ps-dev libhdf5-mpi-dev libhdf5-openmpi-dev libnetcdf-cxx-legacy-dev libogg-dev libtheora-dev libvtk7.1 libvtk7.1-qt
python3-attr python3-autobahn python3-automat python3-cbor python3-constantly python3-hyperlink python3-incremental python3-lz4
python3-mpi4py python3-pam python3-pyasn1 python3-pyasn1-modules python3-qrcode python3-serial python3-service-identity python3-snappy
python3-trie python3-twisted python3-twisted-bin python3-txaio python3-u-msgpack python3-ubjson python3-vtk7 python3-wsaccel tcl-vtk7
vtk7
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libvtk6.3-qt
The following packages will be REMOVED:
libvtk7-dev libvtk7-java libvtk7-jni
The following NEW packages will be installed:
libvtk6-jni libvtk6.3-qt
0 upgraded, 2 newly installed, 3 to remove and 1 not upgraded.
Need to get 4,592 kB of archives.
After this operation, 32.6 MB disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 libvtk6.3-qt amd64 6.3.0+dfsg1-11build1 [244 kB]
Get:2 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 libvtk6-jni amd64 6.3.0+dfsg1-11build1 [4,348 kB]
Fetched 4,592 kB in 18s (249 kB/s)
(Reading database ... 308259 files and directories currently installed.)
............
Unpacking libvtk6-jni (6.3.0+dfsg1-11build1) ...
Setting up libvtk6.3-qt (6.3.0+dfsg1-11build1) ...
Setting up libvtk6-jni (6.3.0+dfsg1-11build1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.4) ...

/proj/hankf/slam/$ sudo apt install libvtk6-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
cython libjs-sphinxdoc libjs-underscore libvtk6-java python-attr python-autobahn python-automat python-cbor python-click python-colorama
python-concurrent.futures python-constantly python-hyperlink python-incremental python-lz4 python-mpi4py python-nacl python-openssl
python-pam python-pyasn1-modules python-qrcode python-serial python-service-identity python-snappy python-trie python-trollius
python-twisted python-twisted-bin python-twisted-core python-txaio python-u-msgpack python-ubjson python-vtk6 python-wsaccel
python-zope.interface tcl-vtk6 vtk6
Suggested packages:
cython-doc vtk6-doc vtk6-examples java-virtual-machine python-attr-doc python-nacl-doc python-openssl-doc python-openssl-dbg
python-pam-dbg python-trie-doc python-twisted-bin-dbg python-gtk2 python-glade2 python-qt3 python-txaio-doc mayavi2
The following NEW packages will be installed:
cython libjs-sphinxdoc libjs-underscore libvtk6-dev libvtk6-java python-attr python-autobahn python-automat python-cbor python-click
python-colorama python-concurrent.futures python-constantly python-hyperlink python-incremental python-lz4 python-mpi4py python-nacl
python-openssl python-pam python-pyasn1-modules python-qrcode python-serial python-service-identity python-snappy python-trie
python-trollius python-twisted python-twisted-bin python-twisted-core python-txaio python-u-msgpack python-ubjson python-vtk6
python-wsaccel python-zope.interface tcl-vtk6 vtk6
0 upgraded, 38 newly installed, 0 to remove and 1 not upgraded.
Need to get 11.5 MB of archives.
After this operation, 64.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 cython amd64 0.26.1-0.4 [1,874 kB]
............
Fetched 11.5 MB in 42s (272 kB/s)
Extracting templates from packages: 100%
Selecting previously unselected package cython.
(Reading database ... 304586 files and directories currently installed.)
Preparing to unpack .../00-cython_0.26.1-0.4_amd64.deb ...
Unpacking cython (0.26.1-0.4) ...
............
Setting up python-vtk6 (6.3.0+dfsg1-11build1) ...
Setting up libvtk6-dev (6.3.0+dfsg1-11build1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

/proj/hankf/slam/$ sudo apt install ros-melodic-perception
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libflann-dev libflann1.9 libopenni-dev libopenni-sensor-pointclouds0 libopenni0 libopenni2-0 libopenni2-dev libpcl-apps1.8
libpcl-common1.8 libpcl-dev libpcl-features1.8 libpcl-filters1.8 libpcl-io1.8 libpcl-kdtree1.8 libpcl-keypoints1.8 libpcl-ml1.8
libpcl-octree1.8 libpcl-outofcore1.8 libpcl-people1.8 libpcl-recognition1.8 libpcl-registration1.8 libpcl-sample-consensus1.8
libpcl-search1.8 libpcl-segmentation1.8 libpcl-stereo1.8 libpcl-surface1.8 libpcl-tracking1.8 libpcl-visualization1.8
libqt5designercomponents5 libqt5quickparticles5 libqt5quicktest5 libqt5quickwidgets5 libqt5webkit5-dev libvtk6-qt-dev openni-utils
qt5-assistant qt5-qmltooling-plugins qtdeclarative5-dev qttools5-dev qttools5-dev-tools qttools5-private-dev
ros-melodic-camera-calibration ros-melodic-compressed-depth-image-transport ros-melodic-compressed-image-transport
ros-melodic-depth-image-proc ros-melodic-image-common ros-melodic-image-geometry ros-melodic-image-pipeline ros-melodic-image-proc
ros-melodic-image-publisher ros-melodic-image-rotate ros-melodic-image-transport-plugins ros-melodic-image-view
ros-melodic-laser-assembler ros-melodic-laser-filters ros-melodic-laser-pipeline ros-melodic-pcl-conversions ros-melodic-pcl-msgs
ros-melodic-pcl-ros ros-melodic-perception-pcl ros-melodic-stereo-image-proc ros-melodic-tf2-eigen ros-melodic-tf2-geometry-msgs
ros-melodic-theora-image-transport ros-melodic-vision-opencv
Suggested packages:
openni-doc openni2-doc libpcl-doc qt5-doc
The following NEW packages will be installed:
libflann-dev libflann1.9 libopenni-dev libopenni-sensor-pointclouds0 libopenni0 libopenni2-0 libopenni2-dev libpcl-apps1.8
libpcl-common1.8 libpcl-dev libpcl-features1.8 libpcl-filters1.8 libpcl-io1.8 libpcl-kdtree1.8 libpcl-keypoints1.8 libpcl-ml1.8
libpcl-octree1.8 libpcl-outofcore1.8 libpcl-people1.8 libpcl-recognition1.8 libpcl-registration1.8 libpcl-sample-consensus1.8
libpcl-search1.8 libpcl-segmentation1.8 libpcl-stereo1.8 libpcl-surface1.8 libpcl-tracking1.8 libpcl-visualization1.8
libqt5designercomponents5 libqt5quickparticles5 libqt5quicktest5 libqt5quickwidgets5 libqt5webkit5-dev libvtk6-qt-dev openni-utils
qt5-assistant qt5-qmltooling-plugins qtdeclarative5-dev qttools5-dev qttools5-dev-tools qttools5-private-dev
ros-melodic-camera-calibration ros-melodic-compressed-depth-image-transport ros-melodic-compressed-image-transport
ros-melodic-depth-image-proc ros-melodic-image-common ros-melodic-image-geometry ros-melodic-image-pipeline ros-melodic-image-proc
ros-melodic-image-publisher ros-melodic-image-rotate ros-melodic-image-transport-plugins ros-melodic-image-view
ros-melodic-laser-assembler ros-melodic-laser-filters ros-melodic-laser-pipeline ros-melodic-pcl-conversions ros-melodic-pcl-msgs
ros-melodic-pcl-ros ros-melodic-perception ros-melodic-perception-pcl ros-melodic-stereo-image-proc ros-melodic-tf2-eigen
ros-melodic-tf2-geometry-msgs ros-melodic-theora-image-transport ros-melodic-vision-opencv
0 upgraded, 66 newly installed, 0 to remove and 1 not upgraded.
Need to get 22.5 MB of archives.
..................
Extracting templates from packages: 100%
Selecting previously unselected package libopenni0.
(Reading database ... 310687 files and directories currently installed.)
Preparing to unpack .../00-libopenni0_1.5.4.0-14build1_amd64.deb ...
Unpacking libopenni0 (1.5.4.0-14build1) ...
Selecting previously unselected package libqt5quickparticles5:amd64.
..................
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for libc-bin (2.27-3ubuntu1.4) ...

/proj/hankf/slam/$ sudo apt install ros-melodic-desktop-full
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
ros-melodic-actionlib-tutorials ros-melodic-common-tutorials ros-melodic-control-toolbox ros-melodic-controller-interface
ros-melodic-controller-manager ros-melodic-controller-manager-msgs ros-melodic-desktop ros-melodic-diff-drive-controller
ros-melodic-forward-command-controller ros-melodic-gazebo-ros-control ros-melodic-geometry-tutorials ros-melodic-hardware-interface
ros-melodic-interactive-marker-tutorials ros-melodic-joint-limits-interface ros-melodic-joint-state-controller
ros-melodic-librviz-tutorial ros-melodic-nodelet-tutorial-math ros-melodic-pluginlib-tutorials ros-melodic-position-controllers
ros-melodic-realtime-tools ros-melodic-ros-tutorials ros-melodic-roscpp-tutorials ros-melodic-roslint ros-melodic-rospy-tutorials
ros-melodic-rviz-plugin-tutorials ros-melodic-rviz-python-tutorial ros-melodic-transmission-interface ros-melodic-turtle-actionlib
ros-melodic-turtle-tf ros-melodic-turtle-tf2 ros-melodic-turtlesim ros-melodic-urdf-sim-tutorial ros-melodic-urdf-tutorial
ros-melodic-visualization-marker-tutorials ros-melodic-visualization-tutorials ros-melodic-viz
The following NEW packages will be installed:
ros-melodic-actionlib-tutorials ros-melodic-common-tutorials ros-melodic-control-toolbox ros-melodic-controller-interface
ros-melodic-controller-manager ros-melodic-controller-manager-msgs ros-melodic-desktop ros-melodic-desktop-full
ros-melodic-diff-drive-controller ros-melodic-forward-command-controller ros-melodic-gazebo-ros-control ros-melodic-geometry-tutorials
ros-melodic-hardware-interface ros-melodic-interactive-marker-tutorials ros-melodic-joint-limits-interface
ros-melodic-joint-state-controller ros-melodic-librviz-tutorial ros-melodic-nodelet-tutorial-math ros-melodic-pluginlib-tutorials
ros-melodic-position-controllers ros-melodic-realtime-tools ros-melodic-ros-tutorials ros-melodic-roscpp-tutorials ros-melodic-roslint
ros-melodic-rospy-tutorials ros-melodic-rviz-plugin-tutorials ros-melodic-rviz-python-tutorial ros-melodic-transmission-interface
ros-melodic-turtle-actionlib ros-melodic-turtle-tf ros-melodic-turtle-tf2 ros-melodic-turtlesim ros-melodic-urdf-sim-tutorial
ros-melodic-urdf-tutorial ros-melodic-visualization-marker-tutorials ros-melodic-visualization-tutorials ros-melodic-viz
0 upgraded, 37 newly installed, 0 to remove and 1 not upgraded.
Need to get 3,091 kB of archives.
After this operation, 14.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
..................
Setting up ros-melodic-forward-command-controller (0.17.2-1bionic.20210921.221517) ...
Setting up ros-melodic-controller-manager (0.18.4-1bionic.20210921.212600) ...
Setting up ros-melodic-desktop (1.4.1-0bionic.20211216.192152) ...
Setting up ros-melodic-position-controllers (0.17.2-1bionic.20210921.224549) ...
Setting up ros-melodic-gazebo-ros-control (2.8.7-1bionic.20211213.200232) ...
Setting up ros-melodic-urdf-sim-tutorial (0.4.0-0bionic.20211216.191012) ...
Setting up ros-melodic-desktop-full (1.4.1-0bionic.20211216.192238) ...

/proj/hankf/slam/$ sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version (12.4ubuntu1).
The following packages were automatically installed and are no longer required:
cython3 libvtk7.1 libvtk7.1-qt python3-attr python3-autobahn python3-automat python3-cbor python3-constantly python3-hyperlink
python3-incremental python3-lz4 python3-mpi4py python3-pam python3-pyasn1 python3-pyasn1-modules python3-qrcode python3-serial
python3-service-identity python3-snappy python3-trie python3-twisted python3-twisted-bin python3-txaio python3-u-msgpack python3-ubjson
python3-vtk7 python3-wsaccel tcl-vtk7 vtk7
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
bzr python-bzrlib python-configobj python-dbus python-gi python-httplib2 python-keyring python-keyrings.alt python-launchpadlib
python-lazr.restfulclient python-lazr.uri python-oauth python-secretstorage python-simplejson python-vcstools python-wadllib
Suggested packages:
bzr-doc bzrtools python-bzrlib.tests python-bzrlib-dbg python-pycurl python-configobj-doc python-dbus-dbg python-dbus-doc python-gi-cairo
libkf5wallet-bin gir1.2-gnomekeyring-1.0 python-fs python-gdata python-keyczar python-testresources python-secretstorage-doc
The following NEW packages will be installed:
bzr python-bzrlib python-configobj python-dbus python-gi python-httplib2 python-keyring python-keyrings.alt python-launchpadlib
python-lazr.restfulclient python-lazr.uri python-oauth python-rosdep python-rosinstall python-rosinstall-generator python-secretstorage
python-simplejson python-vcstools python-wadllib python-wstool
0 upgraded, 20 newly installed, 0 to remove and 1 not upgraded.
Need to get 2,234 kB of archives.
After this operation, 12.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Selecting previously unselected package python-configobj.
(Reading database ... 314878 files and directories currently

Fetched 2,234 kB in 15s (148 kB/s)
............
Setting up python-simplejson (3.13.2-1) ...
Setting up python-configobj (5.0.6-2) ...
Setting up python-bzrlib (2.7.0+bzr6622-10) ...
Setting up bzr (2.7.0+bzr6622-10) ...
update-alternatives: using /usr/bin/bzr.bzr to provide /usr/bin/bzr (bzr) in auto mode
Setting up python-keyrings.alt (3.0-1) ...
Setting up python-httplib2 (0.9.2+dfsg-1ubuntu0.3) ...
Setting up python-vcstools (0.1.42-1) ...
Setting up python-gi (3.26.1-2ubuntu1) ...
Setting up python-rosdep (0.21.0-1) ...
Setting up python-lazr.uri (1.0.3-2build1) ...
Setting up python-oauth (1.0.1-5) ...
Setting up python-dbus (1.2.6-1) ...
Setting up python-rosinstall-generator (0.1.22-1) ...
Setting up python-secretstorage (2.3.1-2) ...
Setting up python-wstool (0.1.17-1) ...
Setting up python-keyring (10.6.0-1) ...
Setting up python-wadllib (1.3.2-3ubuntu0.18.04.1) ...
Setting up python-rosinstall (0.7.8-1) ...
Setting up python-lazr.restfulclient (0.13.5-1) ...
Setting up python-launchpadlib (1.10.6-1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

参考文档
Ubuntu18.04运行ORB-SLAM3

最新文章

最新文章