现在没有可用的软件包vim,但是它被其它的软件包引用了&gcc命令无法使用

1.问题描述

 在终端使用vi hello.c命令时出现以下错误,并且gcc工具也使用不了:

程序 'vim' 已包含在下列软件包中:
* vim
* vim-gnome  
* vim-tiny  
* vim-athena  
* vim-gtk  
* vim-nox  
请尝试:sudo apt-get install <选定的软件包>  

然后我在终端输入sudo apt-get install vim后出现以下错误:

正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
没有可用的软件包 vim,但是它被其它的软件包引用了。
这可能意味着这个缺失的软件包可能已被废弃,
或者只能在其他发布源中找到

2.解决方法

先使用命令sudo apt-get update更新,但是运行后提示没有可用的软件包错误!所以需要修改源地址,首先切换到/etc/apt/目录下,使用命令sudo chmod 777 sources.list改变sources.list文件的属性,“只读”改为“可读写”:

现在没有可用的软件包vim,但是它被其它的软件包引用了&gcc命令无法使用_第1张图片

由于无法使用vi工具,所以在图形界面中打开/etc/apt/source.list文件,选择下面一种源地址,粘贴到文件中,我选择的是网易Ubuntu源:

#网易 Ubuntu 源(速度很快)

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

#中国科技大学 (教育网用户推荐)

    deb http://debian.ustc.edu.cn/ubuntu/ precise main restricted universe multiverse
    deb http://debian.ustc.edu.cn/ubuntu/ precise-backports restricted universe multiverse
    deb http://debian.ustc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
    deb http://debian.ustc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
    deb http://debian.ustc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse
    deb-src http://debian.ustc.edu.cn/ubuntu/ precise main restricted universe multiverse
    deb-src http://debian.ustc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
    deb-src http://debian.ustc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
    deb-src http://debian.ustc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
    deb-src http://debian.ustc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse

#北京理工大学

    deb http://mirror.bjtu.edu.cn/ubuntu/ precise main multiverse restricted universe
    deb http://mirror.bjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe
    deb http://mirror.bjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe
    deb http://mirror.bjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe
    deb http://mirror.bjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe
    deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise main multiverse restricted universe
    deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe
    deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe
    deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe
    deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe

#兰州大学

    deb ftp://mirror.lzu.edu.cn/ubuntu/ precise main multiverse restricted universe
    deb ftp://mirror.lzu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe
    deb ftp://mirror.lzu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe
    deb ftp://mirror.lzu.edu.cn/ubuntu/ precise-security main multiverse restricted universe
    deb ftp://mirror.lzu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe
    deb ftp://mirror.lzu.edu.cn/ubuntu-cn/ precise main multiverse restricted universe

#上海交通大学

    deb http://ftp.sjtu.edu.cn/ubuntu/ precise main multiverse restricted universe
    deb http://ftp.sjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe
    deb http://ftp.sjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe
    deb http://ftp.sjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe
    deb http://ftp.sjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe
    deb http://ftp.sjtu.edu.cn/ubuntu-cn/ precise main multiverse restricted universe
    deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise main multiverse restricted universe
    deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe
    deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe
    deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe
    deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe

现在没有可用的软件包vim,但是它被其它的软件包引用了&gcc命令无法使用_第2张图片


然后在终端输入sudo apt-get update命令完成更新,gcc命令此时可以使用,之后输入sudo apt-get install vim即可成功安装vim,此时vi命令就可以正常使用了。

你可能感兴趣的:(ubuntu)