17

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?

indra bin ridwan
  • 667
  • 1
  • 6
  • 11
  • refer [here](http://askubuntu.com/questions/672338/unable-to-locate-package-python-pandas/672344#672344) enable all as shown in that image! – Ravan Sep 10 '15 at 08:06
  • What's the output of `dpkg --get-selections | grep hold`? – Ron Sep 10 '15 at 08:18

3 Answers3

31

Problem is solved!

I solved this with remove libpq5 :

sudo apt-get remove libpq5
sudo apt-get install libpq-dev
indra bin ridwan
  • 667
  • 1
  • 6
  • 11
  • 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) – user2490003 May 29 '16 at 19:08
  • I have run the commands (including apt-get update), but I still got a problem. Is there any suggestion? – ismailsunni Aug 14 '20 at 08:52
  • This fix no longer works (Ubuntu 18.04) – Zendel Dec 14 '20 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 '22 at 03: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

Zendel
  • 179
  • 1
  • 5
2

The problem can be solved via following steps :

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