Debian 安装 hplip 依赖冲突问题排查与解决

在 Debian 系统上安装打印机驱动(例如 hplip)时,我遇到了一次比较典型的 依赖冲突问题。这里记录一下问题的现象、原因以及解决办法,希望能帮到遇到相同情况的朋友。


问题现象

在 Debian 10 (buster) 上安装 hplip 时,执行:

复制代码
sudo apt install hplip

报错提示缺少依赖,于是尝试单独安装:

复制代码
sudo apt install python3-pil python3-reportlab

结果出现错误:

复制代码
依赖 python3 (< 3.8),但是 3.9.2-3 正要被安装

也就是说,python3-pilpython3-reportlab 这两个包要求的 Python 版本必须小于 3.8,而我系统里已经有了 3.9.2,导致依赖直接冲突,安装失败。


原因分析

  • Debian 10 (buster) 默认自带 Python 3.7

  • 我的系统里不知不觉已经装上了 Python 3.9(很可能是从 bullseye 或 backports 源拉下来的)。

  • 但 buster 源里的 python3-pilpython3-reportlab 等包,依赖关系写死了 python3 (< 3.8)

  • 于是:系统里 Python 太新,依赖包太老 → 冲突。

换句话说,就是 系统处于"Debian 10 + 部分 Debian 11 包"的混合状态,APT 的依赖链被破坏了。


解决方案对比

针对这种情况,有三种思路:

方案 1:回退 Python,保持纯 Debian 10

卸载掉 python3.9,重新装回 3.7,然后再装依赖。

缺点是软件版本老,不推荐。

方案 2:升级系统到 Debian 11 ✅(推荐)

既然 Python 已经是 3.9,干脆把整个系统升级到 Debian 11 (bullseye) ,保持一致性。

操作步骤:

  1. 编辑源列表:

    复制代码
    sudo nano /etc/apt/sources.list

    buster 全部替换为 bullseye

    复制代码
    deb http://deb.debian.org/debian bullseye main contrib non-free
    deb http://deb.debian.org/debian bullseye-updates main contrib non-free
    deb http://security.debian.org/debian-security bullseye-security main contrib non-free
  2. 更新并全面升级:

    复制代码
    sudo apt update
    sudo apt full-upgrade
  3. 安装依赖和 hplip:

    复制代码
    sudo apt install python3-pil python3-reportlab hplip

至此,依赖问题完全解决,hplip 可以正常安装。

方案 3:保持 Debian 10,但用 HP 官方安装脚本

HP 官方提供了 hplip.run 脚本,直接绕过 apt 依赖,自带 Python 检测。

适合不想升级系统的用户。

  • 去官网下载最新版本:

    👉 HP Linux Imaging and Printing (HPLIP)

  • 下载 .run 文件,例如:

    bash 复制代码
    wget https://downloads.sourceforge.net/project/hplip/hplip/3.23.12/hplip-3.23.12.run
  • 安装:

    bash 复制代码
    sh hplip-3.23.12.run
相关推荐
Tyler_TXZ2 小时前
C++C语言之——二叉树
c语言·开发语言·数据结构·c++·二叉树
木白CPP2 小时前
Linux 驱动UART子系统源码分析
linux·运维·服务器·驱动开发·嵌入式硬件·开源软件
不会代码的小猴2 小时前
C++新增关键字
开发语言·c++·笔记
yaoxin5211232 小时前
497. Java 反射 - 使用反射读取注解
java·开发语言·python
RisunJan2 小时前
Linux命令-times(进程累计时间显示)
linux·运维·chrome
2019一路前行2 小时前
Python 函数式编程
开发语言·python
专注仿真3 小时前
问答大模型技术方案算法实现-RAPTOR树构建算法与BEG集成使用
python·算法
冯汉栩3 小时前
Swift Control View,Label渐变颜色(源码)
开发语言·ios·swift
Titan20244 小时前
Linux网络基础知识
linux·服务器·网络·c++·学习
皮皮蟹虾饺4 小时前
NCCL 源码解析:通信器从出生到消亡的完整一生
linux·人工智能·ubuntu·语言模型·kubernetes