在 ubuntu 20.04 中安装 libpq-dev 时出现问题

新手上路,请多包涵

我目前正在尝试安装 libpq-dev 来安装 psycopg2。问题是,当我尝试安装它时,出现错误提示我没有最新的 libpq5 版本。但是,当我尝试下载较新版本的 libpq5 时,系统说我已经拥有最新版本。错误示例。

 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.

原文由 lhmmendes 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 2k
2 个回答

I would say you have installed the latest libpq ( 12.4-1 ) but libpq-dev needs older version ( 12.4-0 ) and this makes problem.

您可以尝试安装旧的 libpq

  apt-get install libpq==12.4-0ubuntu0.20.04.1

但如果其他程序使用最新版本,则旧版本可能会使该程序出现问题。

pgdg20 in 12.4-1.pgdg20.04+1 means it is not module from standard ubuntu repo but from some other repo - probably postgresql repo - and maybe this repo还有最新版本 libpq-dev 。您将在 Google 中搜索 12.4-1.pgdg20.04+1 ,也许您还可以找到 libpg-dev12.4-1.pgdg20.04+1


我找到了 libpq-dev 12.4-1.pgdg20.04+1 ,你可以下载 .deb 文件并安装它。

或者您可以添加此 postgresql 存储库并使用 apt-get 安装。此方法还将通知更新,然后您可以自动安装更新。

原文由 furas 发布,翻译遵循 CC BY-SA 4.0 许可协议

截至 2022 年 11 月下旬,命令是:

 sudo apt-get install libpq5=12.12-0ubuntu0.20.04.1 && sudo apt-get install libpq-dev

当您使用 Ubuntu 22.04 时,请尝试:

 sudo apt-get install libpq5=14.5-0ubuntu0.22.04.1 && sudo apt-get install libpq-dev

原文由 picklepick 发布,翻译遵循 CC BY-SA 4.0 许可协议

推荐问题