我是在Docker的Ubuntu容器上出现的问题
一般apt-get出现这种情况:
`Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package ****
或者
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
`
就是没有更新APT库
更新一下就好了
sudo apt-get update
sudo apt-get upgrade
然后再apt-get install *** 就好了,解决
如果这样不行的话就参考下面的做法
解决Ubuntu17.04不能安装git的问题 E: Package 'git' has no installation candidate
在Ubuntu系统中安装git的命令是:sudo apt install git,但比较奇怪的是,在Ubuntu17.04中输入该命令,却出现以下的情况:
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

没有找到对应软件包'git',Why?以为没有update,但输入apt-get update,还是出现这种问题。后来,发现是更改一下Install的源地址就可以了,方法是:在System settings->software&Updates,勾选“Source code”,在Download from选择other

oftware&Updates,勾选“Source code”,在Download from选择other

点击选择“select Best Server”会自动选择网络最好的服务器,当然或者选择mirror.aliyun.com等国内镜像服务器下载。

然后Choose Server->Close->Reload即可,最后再次输入“sudo apt install git”就可以正常安装git了

然后再次输入安装命令就可以了!
本文详细介绍了在Ubuntu系统,尤其是Ubuntu17.04版本中遇到无法安装git的情况及其解决方案。通过更改软件源地址,如选择阿里云镜像服务器,可以有效解决“Package 'git' has no installation candidate”的错误,使用户能够成功安装git。
2万+

被折叠的 条评论
为什么被折叠?



