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

Ubuntu按官方步骤安装pgadmin4失败,提示无安装候选包如何解决

pgadmin4安装无候选包问题修复方案

报错信息:Package pgadmin4 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source. E: Package 'pgadmin4' has no installation candidate.

你遇到的源配置写入失败问题可通过手动配置源的方式解决,步骤如下:

  • 第一步:确认当前Ubuntu版本代号
    执行命令查看版本代号:
    lsb_release -cs
    命令会输出对应版本的代号,例如22.04对应jammy、20.04对应focal、24.04对应noble,记录该值备用。

  • 第二步:手动写入源配置文件
    执行命令创建并打开源配置文件:
    sudo nano /etc/apt/sources.list.d/pgadmin4.list
    在打开的编辑器中输入以下内容,将<版本代号>替换为上一步查询到的实际值:
    deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/<版本代号> pgadmin4 main
    按下Ctrl+O保存,回车确认文件名,再按下Ctrl+X退出编辑器。
    可执行cat /etc/apt/sources.list.d/pgadmin4.list确认内容是否正确写入。

  • 第三步:导入pgadmin官方公钥
    未导入公钥会导致源校验失败,执行命令导入:
    curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/packages_pgadmin_org.gpg
    若系统未安装curl,先执行sudo apt install -y curl安装即可。

  • 第四步:更新apt缓存并安装
    执行缓存更新命令:
    sudo apt update
    缓存更新完成后即可正常安装pgadmin4:

    • 仅安装桌面端:sudo apt install pgadmin4-desktop
    • 仅安装web端:sudo apt install pgadmin4-web
    • 安装完整版本:sudo apt install pgadmin4

如果官方源访问速度较慢,可将源配置中的地址替换为国内镜像站地址,例如清华源对应地址为https://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/pgadmin/pgadmin4/apt/<版本代号>,其余操作步骤不变。

此前官方命令执行失败的常见原因是精简版Ubuntu系统未预装lsb-release包,导致命令中的变量替换失效,写入的源内容不符合要求,手动填写版本代号即可规避该问题。

内容的提问来源于stack exchange,提问作者Dylanthemachine

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.30 10:54:05