You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 22.04.03安装PostgreSQL 15时遭遇依赖问题求助

Ubuntu 22.04.03安装PostgreSQL 15时遭遇依赖问题求助

我特别理解你跟着官方文档和YouTube教程一步步操作,结果还是卡在依赖报错上的挫败感——咱们一起来把这个问题解决掉。

先把你遇到的错误信息贴出来方便参考:

Reading package lists... Done

Building dependency tree... Done

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:

postgresql-15 : Depends: postgresql-common (>= 241~) but it is not going to be installed

Depends: libllvm14 but it is not installable

Recommends: sysstat but it is not installable

E: Unable to correct problems, you have held broken packages.

接下来是具体的解决步骤:

第一步:修复系统中已损坏的依赖和锁定包

你的错误提示里提到了held broken packages,这说明系统里有被锁定或者未正确配置的包,先处理这个基础问题:

  • 首先更新源并修复缺失的包信息:
    sudo apt update --fix-missing
    
  • 配置所有未完成安装的包:
    sudo dpkg --configure -a
    
  • 自动修复依赖关系:
    sudo apt-get install -f
    
  • 检查是否还有被锁定的包,如果有就取消锁定:
    # 列出所有被锁定的包
    dpkg --get-selections | grep hold
    # 如果输出有包,用下面的命令取消锁定,替换成对应的包名
    sudo apt-mark unhold <package-name>
    

第二步:确保PostgreSQL官方源配置正确

很多时候依赖问题是因为源配置不正确,导致系统找不到合适版本的依赖包,咱们重新配置官方源:

  • 先删除可能存在的错误PostgreSQL源文件:
    sudo rm /etc/apt/sources.list.d/pgdg.list
    
  • 添加正确的官方源:
    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 update
    

第三步:尝试重新安装PostgreSQL 15

做完上面的步骤后,再尝试安装:

sudo apt install postgresql-15

如果还是因为sysstat这个推荐包报错,可以忽略推荐包进行安装:

sudo apt install --no-install-recommends postgresql-15

如果执行完这些步骤还是有问题,可以告诉我后续的错误信息,我再帮你排查~

备注:内容来源于stack exchange,提问作者Firman ismail Hariri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 16:20:25