linux apt-get Package has no installation candidate问题

前言

这个问题的本质,是apt-get所获取的当前本地软件源列表中,没有查找到你要安装的包。

所以解决方式一般有两种:

1.更新apt-get的源列表

2.增加新的apt源

更新apt-get软件源列表

大部分网上是这种方法:

#更新源列表
apt-get update
#升级所有软件包
apt-get upgrade

然后重新install就行了。

增加新的apt源

之前遇到一个问题,ubuntu安装邮件heirloom-mailx的时候,报错这个错。后来发现是因为ubuntu的软件源列表里面没有这个包了,需要新增一个源。

使用vim修改文件/etc/apt/sources.list:

sudo vim /etc/apt/sources.list

然后在列表里面添加heirloom-mailx所需的源:

deb http://cz.archive.ubuntu.com/ubuntu xenial main universe

其它源参考:这里是163镜像

deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

阿里云镜像:

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse                    
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
##測試版源
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
# 源碼
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
##測試版源
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse

然后运行

apt-get update

更新一下apt列表,然后重新install就行了

以上

你可能感兴趣的:(服务器搭建,linux基础,linux)