![使用命令行](https://linux22.com/image/838746/%E4%BD%BF%E7%94%A8%E5%91%BD%E4%BB%A4%E8%A1%8C.png)
apt-get install build-essential
失败并出现以下错误:
~$ sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package build-essential 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 'build-essential' has no installation candidate
sudo apt-get update
在尝试安装之前我刚刚运行过。
文件夹 /etc/apt/sources.list.d 是空的。以下是 /etc/apt/sources.list 的内容:
$ grep deb\ http: /etc/apt/sources.list #(with "deb http://" deleted)
us.archive.ubuntu.com/ubuntu/ raring main restricted
us.archive.ubuntu.com/ubuntu/ raring-updates main restricted
us.archive.ubuntu.com/ubuntu/ raring universe
us.archive.ubuntu.com/ubuntu/ raring-updates universe
us.archive.ubuntu.com/ubuntu/ raring multiverse
us.archive.ubuntu.com/ubuntu/ raring-updates multiverse
us.archive.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse
security.ubuntu.com/ubuntu raring-security main restricted
security.ubuntu.com/ubuntu raring-security universe
security.ubuntu.com/ubuntu raring-security multiverse
extras.ubuntu.com/ubuntu raring main
这是 ubuntu 13.04 64 位。
apt-cache policy build-essential
build-essential:
Installed: (none)
Candidate: (none)
Version table:
目录 /etc/apt/sources.list.d 是空的。
答案1
问题解决了。在 Ubuntu 软件中心 >> 编辑 >> 软件源中,我将服务器更改为主服务器,然后运行sudo apt-get update
。然后sudo apt-get install build-essential
就可以了。
答案2
使用命令行
如果您想使用命令行解决这个烦人的问题。您应该编辑文件/etc/apt/source.list
。
添加行deb http://cz.archive.ubuntu.com/ubuntu bionic main
。cz.archive.ubuntu.com/ubuntu
用替换镜子问题,取决于您的地理位置,您的分布是否是仿生的。如果不是,请输入正确的。