我是在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了
然後再次輸入安裝命令就可以了!