Score:0

Dependency issue

cn flag

I am receiving some errors whenever I try to apt-get install, it tells me it cannot do so because certain packages are "not going to be installed."

I can neither install those packages, uninstall them, nor uninstall any package.

when I do apt --fix-broken install I receive error "E: Sub-process /usr/bin/dpkg returned an error code (1)"

the packages in question are ROS Noetic packages, so familiarity with ROS installation is helpful.

$ sudo apt-get upgrade

[sudo] password for roth: 
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:
 python3-rosdep-modules : Depends: python3-rospkg-modules (>= 1.3.0) but it is not installed
                          Depends: python3-catkin-pkg-modules (>= 0.4.0) but it is not installed
                          Depends: python3-rosdistro-modules (>= 0.7.5) but it is not installed
 ros-noetic-rospack : Depends: python3-catkin-pkg-modules but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

$ sudo apt --fix-broken install:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  python3-catkin-pkg-modules python3-rosdistro-modules python3-rospkg-modules
The following NEW packages will be installed:
  python3-catkin-pkg-modules python3-rosdistro-modules python3-rospkg-modules
0 upgraded, 3 newly installed, 0 to remove and 101 not upgraded.
30 not fully installed or removed.
Need to get 0 B/98.0 kB of archives.
After this operation, 650 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 247423 files and directories currently installed.)
Preparing to unpack .../python3-catkin-pkg-modules_0.4.24-1_all.deb ...
Unpacking python3-catkin-pkg-modules (0.4.24-1) ...
dpkg: error processing archive /var/cache/apt/archives/python3-catkin-pkg-module
s_0.4.24-1_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3/dist-packages/catkin_pkg/__init__.py', wh
ich is also in package python3-catkin-pkg 0.4.24-1
Preparing to unpack .../python3-rospkg-modules_1.3.0-1_all.deb ...
Unpacking python3-rospkg-modules (1.3.0-1) ...
dpkg: error processing archive /var/cache/apt/archives/python3-rospkg-modules_1.
3.0-1_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3/dist-packages/rospkg/__init__.py', which 
is also in package python3-rospkg 1.2.3-1
Preparing to unpack .../python3-rosdistro-modules_0.8.3-1_all.deb ...
Unpacking python3-rosdistro-modules (0.8.3-1) ...
dpkg: error processing archive /var/cache/apt/archives/python3-rosdistro-modules
_0.8.3-1_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3/dist-packages/rosdistro/__init__.py', whi
ch is also in package python3-rosdistro 0.8.0-1
Errors were encountered while processing:
 /var/cache/apt/archives/python3-catkin-pkg-modules_0.4.24-1_all.deb
 /var/cache/apt/archives/python3-rospkg-modules_1.3.0-1_all.deb
 /var/cache/apt/archives/python3-rosdistro-modules_0.8.3-1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Annuore avatar
cn flag
@Nmath thank you for your response. Here's an example of the error http://temporary-url.com/BC761A
Nmath avatar
ng flag
try `sudo apt update` followed by `sudo apt-get dist-upgrade` - `dist-upgrade` is a bit more aggressive in resolving dependency conflicts. I see that there are `101 not upgraded` -- I think this problem could have occurred if/when there were attempts to install new software without first updating the list of available software (`sudo apt update`) or making sure that current software is up-to-date (`sudo apt upgrade`) - you should always make sure that your packages are up-to-date before installing anything new. Hopefully `dist-upgrade` will resolve these issues.
karel avatar
sa flag
Does this answer your question? [dpkg error: "trying to overwrite file, which is also in..."](https://askubuntu.com/questions/176121/dpkg-error-trying-to-overwrite-file-which-is-also-in)
Score:0
my flag

Here is the part of the error you need to look at:

dpkg: error processing archive /var/cache/apt/archives/python3-catkin-pkg-module
s_0.4.24-1_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3/dist-packages/catkin_pkg/__init__.py', wh
ich is also in package python3-catkin-pkg 0.4.24-1
Preparing to unpack .../python3-rospkg-modules_1.3.0-1_all.deb ...
Unpacking python3-rospkg-modules (1.3.0-1) ...
dpkg: error processing archive /var/cache/apt/archives/python3-rospkg-modules_1.
3.0-1_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3/dist-packages/rospkg/__init__.py', which 
is also in package python3-rospkg 1.2.3-1
Preparing to unpack .../python3-rosdistro-modules_0.8.3-1_all.deb ...
Unpacking python3-rosdistro-modules (0.8.3-1) ...
dpkg: error processing archive /var/cache/apt/archives/python3-rosdistro-modules
_0.8.3-1_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3/dist-packages/rosdistro/__init__.py', whi
ch is also in package python3-rosdistro 0.8.0-1
Errors were encountered while processing:
 /var/cache/apt/archives/python3-catkin-pkg-modules_0.4.24-1_all.deb
 /var/cache/apt/archives/python3-rospkg-modules_1.3.0-1_all.deb
 /var/cache/apt/archives/python3-rosdistro-modules_0.8.3-1_all.deb

The error message clearly says that it is trying to overwrite a few files because there is a package that has already created those files. In simple words, the package was supposed to place one of its files in /usr/lib/python3/, but it was shocked to see that those files were already there. It didn't know what to do next, so it started throwing error messages.

If you look carefully, you will see that those packages are placed in /var/cache/apt/archives/. This is apt's cache directory, where it downloads files and waits for dpkg to install them (process them). As they are stored in apt's cache, you'll see that every time you use apt, dpkg starts processing those files (packages).

How to solve the problem?

You can use three different types of commands to solve this problem:

  1. Use dpkg -P to purge packages and fix everything safely (almost...).

    The -P in dpkg means --purge and will remove everything, including settings and configuration files.

    In your case you need to force overwrite:

    dpkg -i --force-overwrite /var/cache/apt/archives/python3-catkin-pkg-modules_0.4.24-1_all.deb
    dpkg -i --force-overwrite /var/cache/apt/archives/python3-rospkg-modules_1.3.0-1_all.deb
    dpkg -i --force-overwrite /var/cache/apt/archives/python3-rosdistro-modules_0.8.3-1_all.deb
    

    Then run:

    sudo apt -f install
    
  2. Use dpkg -i --force-overwrite <file> to make it safer.

    In your case you need to force overwrite:

    dpkg -i --force-overwrite /var/cache/apt/archives/python3-catkin-pkg-modules_0.4.24-1_all.deb
    dpkg -i --force-overwrite /var/cache/apt/archives/python3-rospkg-modules_1.3.0-1_all.deb
    dpkg -i --force-overwrite /var/cache/apt/archives/python3-rosdistro-modules_0.8.3-1_all.deb
    

    Then run:

    sudo apt -f install
    
  3. Use rm to remove those package files (kinda dangerous).

    You can remove all those .deb package files by running:

    sudo rm -r /var/cache/apt/archives/*.deb
    

    Then run:

    sudo apt -f install
    
Notes:
  • Only use one of these methods.
  • 1st and 2nd are recommended.

Be careful!

  • Overwriting things can cause serious trouble if the files are different. One of your conflicting packages will no longer function properly.

  • Dependencies not installed manually will be removed when no packages that are installed depend on them.

  • Generally, if any problem occurs, then running:

    sudo apt install python3-all
    

    will work (at least on Ubuntu 21.10)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.