安装git提示E: Package ‘git‘ has no installation candidate

安装git提示 E: Package ‘git’ has no installation candidate:



问题描述

Linux系统(Ubuntu 18.04.3 )中使用apt工具安装git工具时出现 E: Package ‘git‘ has no installation candidate 问题:

E: Package 'git' has no installation candidate
root@interactive17068:~# apt-get install git
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package git 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 'git' has no installation candidate


解决方案

以下三个原因可能导致安装失败:

原因一

解决方法:在非root用户下安装,权限不够,非root用户的话建议加上sudo:

sudo apt-get install git

原因二

解决方法:由于系统中的apt包版本过低需要更新之后在安装git,依次输入如下两句:

apt-get update
apt-get install git

原因三

Ubuntu 默认使用的官方源的服务器从国内访问速度很慢。可以在装完 Ubuntu 系统后最好把官方源更换为国内的源。安装源出现问题也可能导致apt工具更新过程中出现问题,所以可以通过命令修改系统中的源文件来增加不同的下载源:

(1)查看系统版本

可以通过此命令查看自己系统的版本:

lsb_release -a

(2)修改源文件

修改/etc/apt内的sources.list文件来增加或修改安装源:
提示:在修改之前可以对源文件进行备份以便于修改出错时可以恢复

vim /etc/apt/sources.list

(3)增加国内源

这里给出了了一些经常使用的国内源可根据需要自行添加:

# 清华大学源
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-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

总结

以上就是安装git提示E: Package ‘git‘ has no installation candidate 的解决方法。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值