Sudo apt get install reports an error software properties common: dependencies: Python 3: any (> = 3.3.2-2 ~)

Keywords: Python Linux Ubuntu

1. Problem description

  • If you want to use the command sudo add apt repository PPA: openjdk-r / PPA, but you are prompted that there is no add apt repository command, install it
  • The add apt repository command is part of the software properties common package, so it is OK to install this package.
  • But once reported an error...
    > sudo apt-get install software-properties-common 
    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:
     software-properties-common : Depends: python3:any (>= 3.3.2-2~)
                                  Depends: python3 but it is not going to be installed
                                  Depends: python3-gi but it is not going to be installed
                                  Depends: python3-dbus but it is not going to be installed
                                  Depends: python3-software-properties (= 0.92.37.8) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.
    

2. Problem solving

💢 2.1 modifying the image source (not valid for my question)

If you want to use the source of Tsinghua University, you need to check your system version first, and then select the appropriate image source

cat /proc/version
> Linux version 4.4.0-186-generic (buildd@lcy01-amd64-002) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12) ) #216-Ubuntu SMP Wed Jul 1 05:34:05 UTC 2020

vim /etc/apt/sources.list   
# Add Tsinghua's source to it. Don't delete the previous content. Just keep it and add it
# The source image is annotated by default to improve apt update speed. You can cancel the annotation if necessary
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

# After editing, return to the shell
sudo apt-get update 
# Update the source (will retrieve the newly added apt get source)

Or you can use Ali source. The operations are the same. Just copy it. Remember to sudo apt get update the source.

2.2 self exploration

reference resources:

It gave me some inspiration. Since there is error reporting information and lack of dependence, I'll go all the way to see what's wrong.

sudo apt-get install software-properties-common
>  software-properties-common : Depends: python3:any (>= 3.3.2-2~)
# If this dependency is missing, install it

sudo apt-get install python3
>  python3 : Depends: python3.4 (>= 3.4.0-0~) but it is not going to be installed

# Move on to the next dependency

sudo apt-get install python3.4
> python3.4-minimal : Depends: libpython3.4-minimal (= 3.4.3-1ubuntu1~14.04.7) but it is not going to be installed

# Move on to the next dependency
sudo apt-get install libpython3.4-minimal
> To continue type in the phrase 'Yes, do as I say!'
 ?] `Yes, do as I say! `# This string as like as two peas is required to be knocked in manually.
# However, an error was reported during the execution
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
E: Sub-process /usr/bin/dpkg returned an error code (2)

In addition, refer to: Solutions to Python minimal and other errors during Ubuntu apt get software installation or uninstallation

sudo apt-get update --fix-missing
# Fix missing packages
sudo apt-get autoremove && sudo apt-get clean && sudo apt-get install -f
# Automatic cleaning and repair

After executing the above two commands, go to the installation. This time, different information appears,

sudo apt-get install software-properties-common


This method is ok, but after retrieving the information of all the required 22 packets, the same error is reported as above.

Resolve errors

dpkg: warning: 'find' not found in PATH or not executable
dpkg: error: 1 expected program not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
E: Sub-process /usr/bin/dpkg returned an error code (2)

reference resources: dpkg: warning: 'ldconfig' not found in PATH or not executable when linux mistakenly deletes libc bin and Small pit for ubuntu installation octave
Simply put, you are missing something. You can't find the ldconfig in the / sbin directory. Check your own folder:

  • This folder is empty... Check whether there are / sbin/ldconfig and / sbin/ldconfig.real files in / usr/local/sbin, /usr/sbin and /sbin.
  • Finally, you can see the / sbin/ldconfig and / sbin/ldconfig.real files in the / sbin folder.

    In addition, it seems that libc bin needs to be reinstalled to restore this configuration file in the blog, but this package is actually included in sudo apt get install build essential
sudo apt-get install build-essential
[sudo] password for enadmin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
binutils cpp cpp-4.6 dpkg-dev fakeroot g++ g++-4.6 gcc gcc-4.6
libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
`libc-bin` libc-dev-bin libc6 libc6-dev libdpkg-perl libgomp1 libmpc2 libmpfr4
libquadmath0 libstdc++6-4.6-dev linux-libc-dev manpages-dev

So it shouldn't be this problem.

In addition,

However, you can see that it contains the directory / sbin. If you copy this to the directory / usr/local/sbin, you may not be able to find???

  • Inspired by this, you can see that there is no find program in this zsh shell... Awkward.
  • In fact, under normal circumstances, the problem can be solved here. My special point is that the server is public. Someone blocked the default find command, so I couldn't find it. At the same time, zsh this shell has also been configured, so there has always been a problem.
  • Moreover, the problem of switching between the zsh shell and the bash shell is. You can switch to root. The default shell of root is bash. Use the following command
sudo su
# After entering the password, you enter the root user authority

reference resources:

2.3 switching system shell

reference resources:

Query user default shell

cat /etc/passwd


View current user shell

(base) /sbin > echo $SHELL
/bin/bash

View the types of shell s supported by the current system

(base) /sbin > cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/usr/bin/tmux
/usr/bin/screen
/bin/zsh
/usr/bin/zsh

So I should use bash???

(base) /sbin > echo $SHELL    
/bin/bash
(base) /sbin > find       
zsh: command not found: find

But it's contradictory?? It clearly shows that it is bash's shell, but the error is zsh??

Try switching zsh to bash

chsh -s /bin/bash #Switch to bash
chsh -s /bin/zsh # Switch to zsh

Posted by tron00 on Thu, 14 Oct 2021 22:04:22 -0700