Ubuntu无法安装vim:Package vim is not available, but is referred to by another package.

本文详细介绍了在Ubuntu18.10中安装Vim时遇到的常见问题及解决方案,包括更新源列表和替换为阿里云源的方法,确保Vim安装顺利。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

刚安装的Ubuntu18.10输入 sudo apt-get install vim 安装vim时出现如下问题:

helloworld@helloworld-Inspiron-5537:~$ sudo apt-get install vim
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package vim is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'vim' has no installation candidate

这个问题的原因是ubuntu的/etc/apt/source.list中的源比较旧了,需要更新一下,更新方法:

$ sudo apt-get update

更新完毕之后,再使用 sudo apt-get install vim 安装应该就没有问题了。

 

如果还有问题,就说明你的源有问题->

1.保险做法先备份源文件:  cp -i /etc/apt/sources.list /etc/apt/sources.list_backup

2.打开sources.list:   sudo gedit /etc/apt/sources.list   

3.在源文件中复制粘贴如下阿里云的源到文件的最前边,然后保存退出。

deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

4.更新:sudo apt-get update

5.更新后,再安装vim,sudo apt-get install vim

这次应该就没有问题了。

 

如何修改源列表

http://wiki.ubuntu.org.cn/%E6%BA%90%E5%88%97%E8%A1%A8#Vivid.2815.04.29.E7.89.88.E6.9C.ACsudo%20gedit%20/etc/apt/sources.list

服務器列表

http://wiki.ubuntu.org.cn/%E6%A8%A1%E6%9D%BF:18.04source

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值