Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems instaling libpq-dev in ubuntu 20.04

I am currently trying to install libpq-dev to install psycopg2. The problem is, when I try to install it, an error occurs saying I don't have the latest libpq5 version. However when I try to download the newer version of libpq5 the system says that I already have the latest version. An example of the error.

lhmendes@lhmendes-GA-78LMT-S2P:~$ sudo apt-get install libpq-dev
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:
 libpq-dev : Depends: libpq5 (= 12.4-0ubuntu0.20.04.1) but 12.4-1.pgdg20.04+1 is to be installed
E: Unable to correct problems, you have held broken packages.
lhmendes@lhmendes-GA-78LMT-S2P:~$ sudo apt-get install libpq5
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libpq5 is already the newest version (12.4-1.pgdg20.04+1).
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
like image 910
lhmmendes Avatar asked Sep 07 '20 23:09

lhmmendes


People also ask

What is Libpq Dev?

libpq is a set of library functions that allow client programs to pass queries to the PostgreSQL backend server and to receive the results of these queries. libpq is also the underlying engine for several other PostgreSQL application interfaces, including those written for C++, Perl, Python, Tcl and ECPG.

How do I install Libpq Dev on Windows?

Download one of the "core" files for the particular version you're looking for. You'll get a tarball that if you expand you'll find a "libpq" folder. Where that should go on your system depends on what kind of development toolchain you're using.


2 Answers

Any newer version of libpq5 can cause this error. In my case it was libpq5=13.1-1.pgdg20.04+1. It's the similar answer as furus has given but the change is it's libpq5 in ubuntu 20.04 (atleast in my case). I fixed the issue by installing

sudo apt-get install libpq5=12.5-0ubuntu0.20.04.1

and then install liqpq-dev again

sudo apt-get install libpq-dev
like image 101
Yash singh Bishen Avatar answered Oct 04 '22 05:10

Yash singh Bishen


As of late October 2022 the command is:

sudo apt-get install libpq5=12.12-0ubuntu0.20.04.1 && sudo apt-get install libpq-dev
like image 22
picklepick Avatar answered Oct 04 '22 04:10

picklepick