16

I can not install libpq-dev for postgresql, i tried

sudo apt-get install libpq-dev

and output

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:
 libpq-dev : Depends: libpq5 (= 9.3.9-0ubuntu0.14.04) but 9.4.4-1.pgdg14.04+1 is to be installed
E: Unable to correct problems, you have held broken packages.

how to fix this problem?

2
  • refer here enable all as shown in that image!
    – Ravan
    Sep 10, 2015 at 8:06
  • What's the output of dpkg --get-selections | grep hold?
    – Ron
    Sep 10, 2015 at 8:18

3 Answers 3

30

Problem is solved!

I solved this with remove libpq5 :

sudo apt-get remove libpq5
sudo apt-get install libpq-dev
4
  • 1
    So simple! FYI - I had to sudo apt-get update first because I didn't have the latest sources (running on DigitalOcean's Ubuntu 14.04 image, which is probably a bit old) May 29, 2016 at 19:08
  • I have run the commands (including apt-get update), but I still got a problem. Is there any suggestion? Aug 14, 2020 at 8:52
  • This fix no longer works (Ubuntu 18.04)
    – Zendel
    Dec 14, 2020 at 19:16
  • Not really a solution, as removing libpq5 requires removing everything that depends on it, which includes Postgres and everything that uses Postgres. I'm not deleting every single database on my system just to fix an Ubuntu packaging bug...
    – Cerin
    Aug 28, 2022 at 3:35
3

To fix this, I had to add postgresql's repo:

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get -y update
sudo apt-get remove libpq5
sudo apt-get install libpq-dev

2
  • Thank you so much you made by day :) Mar 26, 2021 at 12:41
  • Removing libpq5 removes Postgres...
    – Cerin
    Aug 28, 2022 at 3:38
2

The problem can be solved via following steps :

sudo apt-get update
sudo apt-get remove libpq5
sudo apt-get install libpq-dev

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .