尝试安装build-essential时“没有安装候选者”

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为空。

问题解决了。 在Ubuntu软件中心>>编辑>>软件源,我将服务器更改为主服务器,然后运行sudo apt-get update 。 然后sudo apt-get install build-essential工作。