Ubuntu 20.04 依赖包安装错误解决方案

一、排除问题

  之前因为国内使用官方源更新 apt 速度太慢, 所以后来换成了阿里源, 但是之后有一次在安装的时候手抖按到 ctrl + c 了 :), 然后悲剧就开始了...

image.png

  再次安装的时候就会如图所示报错出现这一串

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

  于是我尝试使用 apt --fix-broken install 又会出现下图的疯狂报错找不到文件.

image.png

  google之后用过sudo apt autoremove sudo apt-get install -f
  等等指令都没有用.

  最后我发现是我软件源配置的是18.04的模板, 然而我是20.04...这里一定要注意不同版本的ubuntu如果软件源的模板没有对应上, 很有可能出现问题.

  比如 ubuntu 18.04 对应的是

deb http://cn.archive.ubuntu.com/ubuntu/ boinc main restricted universe multiverse

  而 ubuntu 20.04 则是

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

  他们的版本代号是不同的!!!

二、解决问题:更换正确的软件源

 1.更改之前先记得备份一下

# 首先备份源列表
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup
  1. 打开sources.list文件修改, 换成对应版本的软件源, 国内一半用阿里云中科大清华比较快.
# 打开sources.list文件
sudo vim /etc/apt/sources.list
#  阿里源 Ubuntu 18.04
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
# 中科大源 Ubuntu 20.04
deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
  1. 刷新列表
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential
  1. 重新执行 fix 问题就解决啦
sudo apt --fix-broken install

你可能感兴趣的:(ubuntu,linux,环境配置)