I am getting error while using sudo apt-get upgrade stating:

dpkg: error processing libgfortran3:amd64 (--configure):
  package libgfortran3:amd64 is not ready for configuration
  cannot configure (current status `half-installed')
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

It does not seem to block the installation/upgrade other applications. I believe this problem arose due to direct shutting down of my PC while the application was being upgraded.

How can I fix this?

sudo dpkg --remove --force-remove-reinstreq --dry-run libgfortran3:amd64

That's just a dry-run. I'm not sure what removing libgfortran3 will take with it but run that and see. Assuming it's not going to gobble the whole system, run it again without the --dry-run and then you can sudo apt-get install ... the packages you need back.

| improve this answer | |
  • 4
    Worked out, thanks! For the record, I ran it and it said dpkg: warning: package is in a very bad inconsistent state; you should reinstall it before attempting a removal so I downloaded the package manually from packages.ubuntu.com and ran sudo dpkg -i WHERE/THE/DOWNLOADED/PACKAGE/IS. Then it became all good. – Bora M. Alper Mar 15 '15 at 11:51
  • 1
    In my case, after following these instructions, just running 'apt-get install -f' reinstalled the package and also fixed several others with broken dependencies because of it. This was for the libx11-data package on debian 7. – bchurchill Apr 28 '15 at 12:13
  • Without --dry-run, as you said, it worked for me. Thank you! – forvas Jan 24 '18 at 17:47

For the half installed package error, --reinstall worked for me:

sudo apt-get install --reinstall packagename 
| improve this answer | |
  • 1
    Yes, but a warning that after reinstalling packagename, apt-get will then proceed to configure any half-configured packages. – Cedric Knight Oct 23 '15 at 13:53
  • 5
    this is safer than the accepted answer imho. – Zanna Jun 25 '17 at 14:44
  • sudo apt-get install --reinstal ncurses-base and later I ran the sudo apt-get update using the root user (sudo -s), it worked just like that... – ArifMustafa Jun 13 '18 at 2:36
  • great. only that solution solved my problem – iWizard Jul 4 '18 at 13:33
  • this did it for me. php-pear was giving me an headache. thanks! – pcarvalho May 25 '19 at 22:27
sudo apt install --reinstall packagename

This works like charm. It resolved an issue that I had been experiencing for months. My case was with the package libmysqlcppconn7v5

All I did was run sudo apt install --reinstall libmysqlcppconn7v5

| improve this answer | |

I got a same "half-installed package" problem with a package kibana. I got the following error:

dpkg: error processing kibana (--configure):
package kibana is not ready for configuration
cannot configure (current status 'half-installed')
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

If anyone is still facing this kind of problem, then you can try this:

sudo rm /var/lib/dpkg/info/kibana*
cd /var/cache/apt/archives
sudo rm kibana*
apt-get --reinstall install kibana

This works for me. You just need to replace the word 'kibana' with your half-installed package name.

| improve this answer | |

If you want to fix this through GUI, you can use synaptic. Synaptic is an excellent package management tool that used to be included in older versions of ubuntu. To install it:

sudo apt-get install synaptic

click on fix broken packages.

| improve this answer | |
  • synaptic does not list the package in broken category :( – Barun Jul 2 '14 at 8:00

This should fix your problem without re-installing the package.

sudo dpkg --force-remove-reinstreq --remove <package_name here>

Followed by: sudo apt-get update

| improve this answer | |
  • Why --force-remove-reinstreq? The package manager doesn't state that a re-installation is required. Generally, a regular removal works just fine for unconfigured packages. -1 – David Foerster Sep 12 '16 at 20:21
  • It's just what I do when sudo apt-get remove <package is out of option and I don't want to re-install that half-installed package .Then, I use --force-remove-reinstreq to remove those junks.. PS : It's on Linux Mint.. I doubt if it'll be any different as Linux is based on Ubuntu.. – c0degeas Sep 13 '16 at 21:44
  • 1
    The package manager works the same in all Debian-based distributions (that's what dpkg stands for after all), but you shouldn't use --force-* "just in case". The error messages are there for a reason and shouldn't be taken lightly by inexperienced users, which is why you shouldn't suggest unnecessary --force-* options to them. Otherwise we could just recommend to always use --force-all or, better yet, remove the --force-* options from dpkg altogether and have them be the default behaviour because that would be easier and more convenient. – David Foerster Sep 13 '16 at 22:28
  • Okay, Admit it... I was being more concerned about getting the job done than, knowing what and how exactly it is done.. Apologies.. – c0degeas Sep 13 '16 at 23:31
  • Hm… I'm just seeing that the accepted answer suggests the same. So I might be wrong about --force-remove-reinstreq being unnecessary. But that also means that your answer is (almost) a duplicate of it. Better luck next time. – David Foerster Sep 13 '16 at 23:47

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