ubuntu 通过 apt-get 安装软件失败时的解决方案
ubuntu通过 apt-get 安装软件失败时的解决方案
最近在 vmware上的ubuntu系统下安装 软件时出现安装失败情况,在网上搜了一通,终于找到了解决方案。遇到的问题和解决方案如下:
一、 apt-get install vim
提示如下:
“E: Package ‘vim’ has no installation candidate”
解决方案:
sudo apt-get update
二、 apt-get update时网络连接失败
解决方案为替换软件镜像:
sudo vi /etc/apt/sources.list
将内存容替换为阿里云的镜像地址:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multivers
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
或者使用清华的镜像地址:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
三、 提示镜像秘钥丢失
提示如下:
Err:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32
Err:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32
Err:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32
Err:4 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32
Err:5 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32
解决方案:sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 3B4FE6ACC0B21F32 (密钥要和提示的一致)
或者: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 公钥
四、提示apt源版本不一致
t通过 apt-get install g++ 安装时提示如下图:
这是因为当前版本与 apt 镜像源的版本代号不一致导致的,需要通过 lsb_release -a 查看当前ubuntu系统的版本。
将 kinetic 替换之前的阿里云地址中的 ubuntu 版本代号,修改后如下:
deb http://mirrors.aliyun.com/ubuntu/ kinetic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ kinetic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ kinetic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ kinetic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ kinetic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ kinetic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ kinetic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ kinetic-backports main restricted universe multivers
deb http://mirrors.aliyun.com/ubuntu/ kinetic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ kinetic-proposed main restricted universe multiverse
这里贴上这个问题文章:大佬的文章:https://blog.csdn.net/WU2629409421perfect/article/details/110881141
到此为止就可以顺利的通过 apt-get install 安装软件了
四、 高版本安装低版本的软件
参考文章:https://linuxconfig.org/how-to-downgrade-ubuntu-linux-system-to-its-previous-version
某些时候可能会需要安装低版本的 ubuntu 镜像, 但是部分低版本的镜像官网已经不提供安装包了。这个时候直接安装就会安装失败,会提示如下没有 Release file 的错误:
可以选择安装一个低版本的包来解决这个问题。比如系统是 18.10 (Cosmic Cuttlefish)的,可以选择安装 18.04 (Bionic Beaver)。相关设置如下:
先把 /etc/apt/sources.list 里面的镜像换成 Bionic。
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multivers
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
然后再将 /etc/apt/preferences 改写成(假如没有这个文件就创建一个):
Package: *
Pin: release a=bionic
Pin-Priority: 1001
至此,就可以安装低版本的软件包了。
更多推荐
所有评论(0)