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

Ubuntu 22.04升级因依赖未满足失败,常规修复方法无效求助

Ubuntu 22.04升级因依赖未满足失败,常规修复方法无效求助

问题描述

从昨天开始,我没法正常升级Ubuntu 22.04.2 LTS系统了。运行sudo apt-get upgrade时弹出了依赖错误:

Reading package lists... Done

Building dependency tree... Done

Reading state information... Done

You might want to run 'apt --fix-broken install' to correct these.

The following packages have unmet dependencies:

unixodbc : Depends: odbcinst1debian2 (>= 2.3.11) but it is not installed

Depends: libodbc1 (>= 2.3.11) but it is not installed

unixodbc-dev : Depends: odbcinst1debian2 (= 2.3.11) but it is not installed

E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

试过运行sudo apt --fix-broken install,也手动装过libodbc1,但都没解决问题。之前为了测试装过Microsoft SQL Server,怀疑和这个有关,但搜来的相关方案也不管用。

我的sudo apt update输出如下:

Hit:1 http://dl.google.com/linux/chrome/deb stable InRelease

Hit:2 http://fr.archive.ubuntu.com/ubuntu jammy InRelease

Hit:3 http://fr.archive.ubuntu.com/ubuntu jammy-updates InRelease

Hit:4 http://packages.microsoft.com/repos/code stable InRelease

Hit:5 http://fr.archive.ubuntu.com/ubuntu jammy-backports InRelease

Get:6 https://packages.microsoft.com/ubuntu/20.04/mssql-server-preview focal InRelease [7 383 B]

Hit:7 https://packages.microsoft.com/ubuntu/20.04/prod focal InRelease

Get:8 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]

Hit:9 https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/ InRelease

Hit:10 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu jammy InRelease

Hit:11 https://packages.gitlab.com/gitlab/gitlab-ee/ubuntu jammy InRelease

Fetched 118 kB in 1s (94,7 kB/s)

Reading package lists... Done

Building dependency tree... Done

Reading state information... Done

19 packages can be upgraded. Run 'apt list --upgradable' to see them.

问题分析

从apt更新日志能找到关键问题:你用的是Ubuntu 22.04(jammy),但系统里混进了Microsoft的Ubuntu 20.04(focal)源。这会导致软件包版本不兼容——unixodbc相关包想从focal源拿2.3.11版本,但jammy源里的对应包版本和这个要求不匹配,直接触发了依赖冲突。

解决步骤

  1. 禁用不兼容的focal源
    先打开终端,列出所有已配置的源文件:

    ls /etc/apt/sources.list.d/
    

    找到包含packages.microsoft.com/ubuntu/20.04的文件(比如mssql-server-preview.list或prod.list),用文本编辑器打开并注释掉里面的focal源条目(在开头加#):

    sudo nano /etc/apt/sources.list.d/[对应的文件名].list
    

    编辑完按Ctrl+O保存,Ctrl+X退出编辑器。

  2. 清理缓存并更新源列表
    运行以下命令清理旧缓存,重新拉取正确的源信息:

    sudo apt clean
    sudo apt update
    
  3. 重新修复依赖
    再次尝试修复损坏的依赖关系:

    sudo apt --fix-broken install
    
  4. 如果仍有问题,强制安装jammy版本的unixodbc包
    要是上面的步骤没解决,直接指定安装Ubuntu 22.04默认版本的相关包:

    sudo apt install -y unixodbc=2.3.9-5ubuntu1 odbcinst1debian2=2.3.9-5ubuntu1 libodbc1=2.3.9-5ubuntu1 unixodbc-dev=2.3.9-5ubuntu1
    

    (注:可以先通过apt show unixodbc确认当前jammy源的版本号,确保和上面的版本一致)

  5. 完成系统升级
    依赖修复好之后,重新运行升级命令:

    sudo apt upgrade
    

备注:内容来源于stack exchange,提问作者makkreker

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.23 12:07:33