sudo apt-get install 报错 software-properties-common : Depends: python3:any (>= 3.3.2-2~)

1. 问题描述

  • 想使用sudo add-apt-repository ppa:openjdk-r/ppa这个命令,但是提示没有add-apt-repository命令,股进行安装
  • add-apt-repository 命令是software-properties-common包的一部分,因此安装这个包就OK了。
  • 但是一度报错。。。
    > 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. 解决问题

💢2.1 修改镜像源(对我的问题无效)

如果要使用清华的源,需要先查看自己系统版本,再去选择合适的镜像源

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   
# 在其中加入清华的源 不要删除之前的内容,都保留加上去就可以
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
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

# 编辑完成,回到shell中
sudo apt-get update 
# 更新一下源 (会去检索刚刚新加的apt-get源)

或者可以使用阿里源,操作都一样,复制上去就行,记得sudo apt-get update一下源。


2.2 自己摸索

参考:

给了我一些启发,既然有报错信息,缺什么依赖,那就一路安到底,看到底哪里出了问题。

sudo apt-get install software-properties-common
>  software-properties-common : Depends: python3:any (>= 3.3.2-2~)
# 缺这个依赖,那就安装这个依赖

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

# 继续看下一个依赖

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

# 继续看下一个依赖
sudo apt-get install libpython3.4-minimal
> To continue type in the phrase 'Yes, do as I say!'
 ?] `Yes, do as I say! `# 这个字符串需要自己手动敲进去,要长得一模一样
# 不过这个执行的时候报错了
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)

另外,参考:ubuntu apt-get安装或卸载软件时出现了python-minimal等错误问题的解决方法

sudo apt-get update --fix-missing
# 修复缺失的包
sudo apt-get autoremove && sudo apt-get clean && sudo apt-get install -f
# 自动清理 修复

执行完上述两条命令之后,再去进行安装,这次出现了和之前不同的信息,

sudo apt-get install software-properties-common

在这里插入图片描述
这种方式是ok的,但是,在检索到所有需要的22个包的信息之后,报了和上面一样的错误。
在这里插入图片描述
解决错误

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)

参考:linux误删libc-bin出现dpkg: warning: ‘ldconfig’ not found in PATH or not executableubuntu安装octave的小坑
简单来说,就是缺东西了,找不到/sbin目录下的ldconfig了,查看自己文件夹:
在这里插入图片描述

  • 这个文件夹竟然是空的。。。分别查看/usr/local/sbin, /usr/sbin and /sbin这三个文件夹下有没有/sbin/ldconfig/sbin/ldconfig.real文件。
  • 最后在/sbin这个文件夹中看到了/sbin/ldconfig/sbin/ldconfig.real这两个文件。
    在这里插入图片描述
    另外,博客中好像要复原这个配置文件,需要重新安装libc-bin,但是这个包其实是包含在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

所以应该不是这个问题。

另外,

但是可以看到,其中是包含/sbin这个目录的,那把这个复制过去,复制到/usr/local/sbin这个目录中,也许是真的找不到???

  • 启发之下,可以看到,这个zsh的shell里就没有find这个程序。。。尴尬。
    在这里插入图片描述
  • 其实常规情况下,问题到这里就可以解决了。 我的特殊在于,服务器是公用的,有人把默认的find命令屏蔽了,所以一直找不到。同时zsh这个shell也是被人配置过了,所以一直有问题。
  • 而且这个zsh的shell和bash的shell的切换问题是。可以切换到root用户,root用户默认的shell是bash的shell,使用以下命令
sudo su
# 输入密码之后就进入了root用户权限

参考:

2.3 切换系统shell

参考:

查询用户默认shell

cat /etc/passwd

在这里插入图片描述
查看当前用户shell

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

查看当前系统支持的shell的类型

(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

所以这里我用的应该就是bash???

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

但是就很矛盾??明明显示是bash的shell,但是报错却是zsh??

切换zsh为bash试试

chsh -s /bin/bash #切换成bash
chsh -s /bin/zsh # 切换成zsh
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

吨吨不打野

解决了问题,觉得还行就给点

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值