4

This issue may be related to ROS completely, however, at present, I am not sure about the source of the error. Hence I am posting it in this big community.

I am trying to install ROS Melodic on Ubuntu 18.04.2 LTS PC. Unfortunately, the command sudo apt install ros-melodic-desktop-full failed. Below is the output of the same command, when running again:

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).

It suggests running apt --fix-broken install which I did but it doesn't solve the issue. See below:

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)

I thought of running update and upgrade but got stuck in the same issue. Please see below:

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).

I also tried removing the ros-melodic-desktop-full package but got in vain as shown below:

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).

I am not able to proceed. I found a possible workaround here which suggest removing python-rospkg package but it didn't work either. Please see below:

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

I have no clue now about fixing it. Below is the more information about the 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

Any workaround, please?

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

Afterwards, sudo apt --fix-broken install If you wanna reinstall ros, run sudo apt-get remove ros-* to remove ros. Then, install ROS from https://wiki.ros.org/ROS/Installation

1

I ran into this same issue, and wrote a script to delete the ros installation packages. I had to run it multiple times like this until there was no output.

Here is the script

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)

Run it multiple times until there is no output with (the script is named fixros.py:

sudo apt-get autoremove | fixros.py
2
  • 1
    Thanks Alex. I need to try your suggestion on my PC. However I recently used “Synaptic Package Manager” and removed ROS completely using it. I will try your suggestions to confirm! The next big question is, once you have removed ROS, how do you install it again? Because the whole motive is to have ROS Melodic on Ubuntu 18.04 working.
    – Ravi Joshi
    Mar 11 '19 at 3:17
  • I have not been able to install ros yet. But if I figure it out I will post here. Mar 11 '19 at 3:46
0

Just do :

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.