This question already has an answer here:

When i try to compile in Geany i get the following error:

/bin/sh: 1: gcc: not found

When I run

sudo apt install gcc

This is what is printed on the screen:

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 (>= 7.3.0-12~) but it is not going to be installed
       Recommends: libc6-dev but it is not going to be installed or
E: Unable to correct problems, you have held broken packages.

I am using Ubuntu 18.04.1 LTS

marked as duplicate by karel, Zanna, Tom Brossman, Eric Carvalho, pomsky Nov 5 '18 at 18:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Vijay's comment fixed my problem. Thank you Vijay.

The answer is here.

That particular error message may indicate that you have held packages, but it may also indicate a different problem.

You can get a list of actual held packages with:

dpkg --get-selections | grep hold

If there are none, or none look related, then it's probably something else. Check carefully the output of the command you were trying when you got the error message, as there may be other clues in the full output from that command, aside from the error message.

Another method of troubleshooting may be to use aptitude rather than apt-get to try to install your package:

sudo aptitude install gcc

Aptitude will give up less easily, and will attempt to find solutions which may involve modifying other packages. It may give you more explanation of the problem and options for fixing it.

Occasionally aptitude will be too eager to remove or downgrade large numbers of packages to satisfy your request, in which case retrying with -f changes its priorities and helps it come up with solutions that involve removing/downgrading fewer packages even if it means not all changes you requested can go ahead:

sudo aptitude -f install gcc

The last two options fixed my problem, i hope that it helps someone else too.

Not the answer you're looking for? Browse other questions tagged or ask your own question.