E: Unable to locate package gcc

Posted Leo_Mine

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了E: Unable to locate package gcc相关的知识,希望对你有一定的参考价值。

如果出现这种报错语句E: Unable to locate package xxx,我先直接给出解决措施:

更换软件源:

deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe

更换软件源之后需输入如下命令:sudo apt-get update,如果报错提示:

Reading package lists... Done
W: GPG error: http://mirrors.aliyun.com/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
E: The repository 'http://mirrors.aliyun.com/ubuntu xenial InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.aliyun.com/ubuntu xenial-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
E: The repository 'http://mirrors.aliyun.com/ubuntu xenial-updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.aliyun.com/ubuntu xenial-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
E: The repository 'http://mirrors.aliyun.com/ubuntu xenial-backports InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.aliyun.com/ubuntu xenial-security InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
E: The repository 'http://mirrors.aliyun.com/ubuntu xenial-security InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://archive.ubuntu.com/ubuntu trusty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
E: The repository 'http://archive.ubuntu.com/ubuntu trusty Release' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

如提示代表签名错误,如无此报错提示,直接跳过即可,如有此报错输入命令更换签名:

40976EAF437D05B5 与 3B4FE6ACC0B21F32 对应报错信息中的数字  根据实际情况输入

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32

以上为解决措施

排查过程如下:

使用的是野火的开发板,开发板并不安装完整系统,所以gcc之类的工具需要自己安装

  1. 出现Unable to locate package gcc后我首先更换了软件源  更换为阿里源,更换后sudo apt update时出现:

debian@npi:/etc/apt$ sudo apt-get update
Get:1 http://mirrors.aliyun.com/ubuntu xenial InRelease [247 kB]
Get:2 http://mirrors.aliyun.com/ubuntu xenial-updates InRelease [99.8 kB]
Get:3 http://mirrors.aliyun.com/ubuntu xenial-backports InRelease [97.4 kB]
Get:4 http://mirrors.aliyun.com/ubuntu xenial-security InRelease [99.8 kB]
Ign:5 http://archive.ubuntu.com/ubuntu trusty InRelease
Get:6 http://archive.ubuntu.com/ubuntu trusty Release [58.5 kB]
Ign:7 http://mirrors.aliyun.com/ubuntu xenial/universe armhf Packages
Ign:8 http://mirrors.aliyun.com/ubuntu xenial/restricted armhf Packages
Ign:9 http://mirrors.aliyun.com/ubuntu xenial/multiverse armhf Packages
Ign:10 http://mirrors.aliyun.com/ubuntu xenial/main armhf Packages
Get:11 http://archive.ubuntu.com/ubuntu trusty Release.gpg [933 B]
Ign:7 http://mirrors.aliyun.com/ubuntu xenial/universe armhf Packages
Ign:8 http://mirrors.aliyun.com/ubuntu xenial/restricted armhf Packages
Ign:9 http://mirrors.aliyun.com/ubuntu xenial/multiverse armhf Packages
Ign:10 http://mirrors.aliyun.com/ubuntu xenial/main armhf Packages
Ign:7 http://mirrors.aliyun.com/ubuntu xenial/universe armhf Packages
Ign:8 http://mirrors.aliyun.com/ubuntu xenial/restricted armhf Packages
Ign:9 http://mirrors.aliyun.com/ubuntu xenial/multiverse armhf Packages
Ign:10 http://mirrors.aliyun.com/ubuntu xenial/main armhf Packages
Ign:7 http://mirrors.aliyun.com/ubuntu xenial/universe armhf Packages
Ign:8 http://mirrors.aliyun.com/ubuntu xenial/restricted armhf Packages
Ign:9 http://mirrors.aliyun.com/ubuntu xenial/multiverse armhf Packages
Ign:10 http://mirrors.aliyun.com/ubuntu xenial/main armhf Packages
Ign:7 http://mirrors.aliyun.com/ubuntu xenial/universe armhf Packages
Ign:8 http://mirrors.aliyun.com/ubuntu xenial/restricted armhf Packages
Ign:9 http://mirrors.aliyun.com/ubuntu xenial/multiverse armhf Packages
Ign:10 http://mirrors.aliyun.com/ubuntu xenial/main armhf Packages
Err:7 http://mirrors.aliyun.com/ubuntu xenial/universe armhf Packages
  404  Not Found [IP: 36.150.79.240 80]
Ign:8 http://mirrors.aliyun.com/ubuntu xenial/restricted armhf Packages
Ign:9 http://mirrors.aliyun.com/ubuntu xenial/multiverse armhf Packages
Ign:10 http://mirrors.aliyun.com/ubuntu xenial/main armhf Packages
Ign:12 http://mirrors.aliyun.com/ubuntu xenial-updates/restricted armhf Packages
Ign:13 http://mirrors.aliyun.com/ubuntu xenial-updates/universe armhf Packages
Ign:14 http://mirrors.aliyun.com/ubuntu xenial-updates/main armhf Packages
Ign:15 http://mirrors.aliyun.com/ubuntu xenial-updates/multiverse armhf Packages
Ign:12 http://mirrors.aliyun.com/ubuntu xenial-updates/restricted armhf Packages
Ign:13 http://mirrors.aliyun.com/ubuntu xenial-updates/universe armhf Packages
Ign:14 http://mirrors.aliyun.com/ubuntu xenial-updates/main armhf Packages
Ign:15 http://mirrors.aliyun.com/ubuntu xenial-updates/multiverse armhf Packages
Ign:12 http://mirrors.aliyun.com/ubuntu xenial-updates/restricted armhf Packages
Ign:13 http://mirrors.aliyun.com/ubuntu xenial-updates/universe armhf Packages
Ign:14 http://mirrors.aliyun.com/ubuntu xenial-updates/main armhf Packages
Ign:15 http://mirrors.aliyun.com/ubuntu xenial-updates/multiverse armhf Packages
Ign:12 http://mirrors.aliyun.com/ubuntu xenial-updates/restricted armhf Packages
Ign:13 http://mirrors.aliyun.com/ubuntu xenial-updates/universe armhf Packages
Ign:14 http://mirrors.aliyun.com/ubuntu xenial-updates/main armhf Packages
Ign:15 http://mirrors.aliyun.com/ubuntu xenial-updates/multiverse armhf Packages
Ign:12 http://mirrors.aliyun.com/ubuntu xenial-updates/restricted armhf Packages
Ign:13 http://mirrors.aliyun.com/ubuntu xenial-updates/universe armhf Packages
Ign:14 http://mirrors.aliyun.com/ubuntu xenial-updates/main armhf Packages
Ign:15 http://mirrors.aliyun.com/ubuntu xenial-updates/multiverse armhf Packages
Err:12 http://mirrors.aliyun.com/ubuntu xenial-updates/restricted armhf Packages
  404  Not Found [IP: 36.150.79.240 80]
Ign:13 http://mirrors.aliyun.com/ubuntu xenial-updates/universe armhf Packages
Ign:14 http://mirrors.aliyun.com/ubuntu xenial-updates/main armhf Packages
Ign:15 http://mirrors.aliyun.com/ubuntu xenial-updates/multiverse armhf Packages
Ign:16 http://mirrors.aliyun.com/ubuntu xenial-backports/main armhf Packages
Ign:17 http://mirrors.aliyun.com/ubuntu xenial-backports/universe armhf Packages
Ign:16 http://mirrors.aliyun.com/ubuntu xenial-backports/main armhf Packages
Ign:17 http://mirrors.aliyun.com/ubuntu xenial-backports/universe armhf Packages
Ign:16 http://mirrors.aliyun.com/ubuntu xenial-backports/main armhf Packages
Ign:17 http://mirrors.aliyun.com/ubuntu xenial-backports/universe armhf Packages
Ign:16 http://mirrors.aliyun.com/ubuntu xenial-backports/main armhf Packages
Ign:17 http://mirrors.aliyun.com/ubuntu xenial-backports/universe armhf Packages
Ign:16 http://mirrors.aliyun.com/ubuntu xenial-backports/main armhf Packages
Ign:17 http://mirrors.aliyun.com/ubuntu xenial-backports/universe armhf Packages
Err:16 http://mirrors.aliyun.com/ubuntu xenial-backports/main armhf Packages
  404  Not Found [IP: 36.150.79.240 80]
Ign:17 http://mirrors.aliyun.com/ubuntu xenial-backports/universe armhf Packages
Ign:18 http://mirrors.aliyun.com/ubuntu xenial-security/restricted armhf Packages
Ign:19 http://mirrors.aliyun.com/ubuntu xenial-security/multiverse armhf Packages
Ign:20 http://mirrors.aliyun.com/ubuntu xenial-security/universe armhf Packages
Ign:21 http://mirrors.aliyun.com/ubuntu xenial-security/main armhf Packages
Ign:18 http://mirrors.aliyun.com/ubuntu xenial-security/restricted armhf Packages
Ign:19 http://mirrors.aliyun.com/ubuntu xenial-security/multiverse armhf Packages
Ign:20 http://mirrors.aliyun.com/ubuntu xenial-security/universe armhf Packages
Ign:21 http://mirrors.aliyun.com/ubuntu xenial-security/main armhf Packages
Ign:18 http://mirrors.aliyun.com/ubuntu xenial-security/restricted armhf Packages
Ign:19 http://mirrors.aliyun.com/ubuntu xenial-security/multiverse armhf Packages
Ign:20 http://mirrors.aliyun.com/ubuntu xenial-security/universe armhf Packages
Ign:21 http://mirrors.aliyun.com/ubuntu xenial-security/main armhf Packages
Ign:18 http://mirrors.aliyun.com/ubuntu xenial-security/restricted armhf Packages
Ign:19 http://mirrors.aliyun.com/ubuntu xenial-security/multiverse armhf Packages
Ign:20 http://mirrors.aliyun.com/ubuntu xenial-security/universe armhf Packages
Ign:21 http://mirrors.aliyun.com/ubuntu xenial-security/main armhf Packages
Ign:18 http://mirrors.aliyun.com/ubuntu xenial-security/restricted armhf Packages
Ign:19 http://mirrors.aliyun.com/ubuntu xenial-security/multiverse armhf Packages
Ign:20 http://mirrors.aliyun.com/ubuntu xenial-security/universe armhf Packages
Ign:21 http://mirrors.aliyun.com/ubuntu xenial-security/main armhf Packages
Err:18 http://mirrors.aliyun.com/ubuntu xenial-security/restricted armhf Packages
  404  Not Found [IP: 36.150.79.240 80]
Ign:19 http://mirrors.aliyun.com/ubuntu xenial-security/multiverse armhf Packages
Ign:20 http://mirrors.aliyun.com/ubuntu xenial-security/universe armhf Packages
Ign:21 http://mirrors.aliyun.com/ubuntu xenial-security/main armhf Packages
Get:22 http://183.207.33.36:9011/archive.ubuntu.com/c3pr90ntc0td/ubuntu trusty/universe Sources [6399 kB]
Ign:23 http://183.207.33.37:9011/archive.ubuntu.com/c3pr90ntc0td/ubuntu trusty/universe armhf Packages
Ign:23 http://183.207.33.37:9011/archive.ubuntu.com/c3pr90ntc0td/ubuntu trusty/universe armhf Packages
Err:23 http://183.207.33.37:9011/archive.ubuntu.com/c3pr90ntc0td/ubuntu trusty/universe armhf Packages
  404  Not Found [IP: 183.207.33.37 9011]
Fetched 6458 kB in 24s (266 kB/s)
Reading package lists... Done
E: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/xenial/universe/binary-armhf/Packages  404  Not Found [IP: 36.150.79.240 80]
E: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/xenial-updates/restricted/binary-armhf/Packages  404  Not Found [IP: 36.150.79.240 80]
E: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/xenial-backports/main/binary-armhf/Packages  404  Not Found [IP: 36.150.79.240 80]
E: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/xenial-security/restricted/binary-armhf/Packages  404  Not Found [IP: 36.150.79.240 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/universe/binary-armhf/Packages  404  Not Found [IP: 183.207.33.37 9011]
E: Some index files failed to download. They have been ignored, or old ones used instead.

并且在出现如上报错的时候试图安装gcc也会出现签名错误

  1. 以上报错信息我才更换另一种软件源:

deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
  1. 重新更换后再执行sudo apt update就不报错了

内容太长
  1. 随后我就正常安装了gcc

内容太长

以上总结出,安装gcc提示定位不到软件换源即可,同时注意签名信息报错

Unable to locate package错误解决办法

更改Ubuntu软件更新源文件 /etc/apt/sourse.list 之后,安装软件 sudo apt-get install gcc 出现错误提示 E: Unable to locate package  

这是因为更新了软件源却没有应用,此时应该执行 sudo apt-get undata 

以上是关于E: Unable to locate package gcc的主要内容,如果未能解决你的问题,请参考以下文章

解决E: Unable to locate package XXX

docker E: Unable to locate package nginx

E: Unable to locate package sysv-rc-conf

问题解决:“E: Unable to locate package sysv-rc-conf“

E: Unable to locate package ros-kinetic-usb-cam

解决Ubuntu18.04安装ros报错E: Unable to locate package ros-melodic-desktop-full