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
相关推荐
扛枪的书生1 小时前
Linux 网络管理器用法速查
linux
小九九的爸爸4 小时前
前端想要入门Agent开发,要具备哪些Python基础?
python·agent·ai编程
顺风尿一寸4 小时前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
阿耶同学5 小时前
手把手教你用 LangGraph 搭建三层嵌套 Agent 架构
python·程序员
XIAOHEZIcode10 小时前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
唐青枫12 小时前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux
花酒锄作田21 小时前
Pydantic校验配置文件
python
hboot21 小时前
AI工程师第四课 - 深度学习入门
pytorch·python·神经网络
ZhengEnCi1 天前
P2M-Matplotlib折线图完全指南-从数据可视化到趋势分析的Python绘图利器
python·matlab·数据可视化
ZhengEnCi1 天前
P2L-Matplotlib饼图完全指南-从数据可视化到图表定制的Python绘图利器
python·matlab