Score:1

I can't install libpq-dev on Ubuntu 20.04.2

cn flag

Problem

I can't install libpq-dev in ubuntu 20.04.2

I ran this command:

$ sudo apt-get update

$ sudo apt-get install libpq-dev

then I got errors bellow.

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.7-0ubuntu0.20.04.1) but 13.3-1.pgdg20.04 + 1 is to be installed
E: Unable to correct problems, you have held broken packages.

Then I try to install the library directly with this command:

$  sudo apt-get install libpq5=12.7-0ubuntu0.20.04.2

I got this error:

Reading package list ... Done
Creating dependency tree
Reading status information ... Done
E: The version «12.7-0ubuntu0.20.04.2» was not found for «libpq5»

Status

Ubuntu version

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:   focal

Kernel version

$ uname -a
Linux IdeaPad-S340-15API 5.8.0-55-generic #62~20.04.1-Ubuntu SMP Wed Jun 2 08:55:04 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Updated

$ apt-cache policy libpq-dev libpq5
libpq-dev:
  Installed: (none)
  Candidate: 12.7-0ubuntu0.20.04.1
  Version table:
     12.7-0ubuntu0.20.04.1 500
        500 http://security.ubuntu.com/ubuntu focal-security / main amd64 Packages
        500 http://archive.ubuntu.com/ubuntu focal-updates / main amd64 Packages
     12.2-4 500
        500 http://archive.ubuntu.com/ubuntu focal / main amd64 Packages
libpq5:
  Installed: 13.3-1.pgdg20.04 + 1
  Candidate: 13.3-1.pgdg20.04 + 1
  Version table:
 *** 13.3-1.pgdg20.04 + 1 500
        500 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 / main amd64 Packages
        100 / var / lib / dpkg / status
     13.2-1.pgdg20.04 + 1 500
        500 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 / main amd64 Packages
     13.1-1.pgdg20.04 + 1 500
        500 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 / main amd64 Packages
     13.0-1.pgdg20.04 + 1 500
        500 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 / main amd64 Packages
     12.7-0ubuntu0.20.04.1 500
        500 http://security.ubuntu.com/ubuntu focal-security / main amd64 Packages
        500 http://archive.ubuntu.com/ubuntu focal-updates / main amd64 Packages
     12.4-1.pgdg20.04 + 1 500
        500 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 / main amd64 Packages
     12.3-1.pgdg20.04 + 1 500
        500 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 / main amd64 Packages
     12.2-4 500
        500 http://archive.ubuntu.com/ubuntu focal / main amd64 Packages
user535733 avatar
cn flag
On your second attempt, looks like you used the wrong version number: Your output says `12.7-0ubuntu0.20.04.1`, but you said that you input `12.7-0ubuntu0.20.04.2`
user535733 avatar
cn flag
The problem with your first attempt is that you have unwisely added a non-Ubuntu source that is providing packages incompatible with your release of Ubuntu (that's what `you have requested an impossible situation` means). You will continue to encounter issues like these until you stop using that source and purge the packages that came from it.
N0rbert avatar
zw flag
Does this answer your question? [How do I restore the default repositories?](https://askubuntu.com/questions/124017/how-do-i-restore-the-default-repositories) . You probably miss *focal-updates*. Please add output of `apt-cache policy libpq-dev libpq5` to find3rd repository.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.