When installing GCC, I encountered the following problems. What Aptitude was found on the Internet, all of which were copied and pasted posts.
(base) [email protected]:~/$ sudo apt install gcc
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
gcc : Depends: gcc (>= 7) but it is not going to be installed
Depends: g++ (>= 7) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Real solutions: Don’t set APT sources in the GUI of Ubuntu, and the source of different versions is different! Intersection
For example, I am a 18.04 Ubuntu. The Ali source set in GUI is reported to this fault. Manual change the source.list to change it, set to the source of 18.04, and then update and update! Intersection Intersection
deb http://mirrors.aliyun.com/ubuntu/ hirsute main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ hirsute-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ hirsute-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ hirsute-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ hirsute-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute-backports main restricted universe multiverse
PS: There are many versions of Ubuntu, and each version has a code, such as Xenial (16.04), Bionic (18.04), Groovy (20.10), Hirsute (21.04). Update the source of other versions of Ubuntu and directly modify the version code of Ubuntu. And no matter how the code changes, the related source of the source is fixed. For example, the source of Tsinghua is https://mirrs.tsuna.edu.cn/ubuntu, Ali’s source is http://mirrs.aliyun.com /ubuntu.
After you change the source, remember to execute:
sudo apt-get update
sudo apt-get upgrade