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
相关推荐
IVEN_4 小时前
只会Python皮毛?深入理解这几点,轻松进阶全栈开发
python·全栈
Ray Liang5 小时前
用六边形架构与整洁架构对比是伪命题?
java·python·c#·架构设计
AI攻城狮5 小时前
如何给 AI Agent 做"断舍离":OpenClaw Session 自动清理实践
python
千寻girling5 小时前
一份不可多得的 《 Python 》语言教程
人工智能·后端·python
AI攻城狮8 小时前
用 Playwright 实现博客一键发布到稀土掘金
python·自动化运维
曲幽9 小时前
FastAPI分布式系统实战:拆解分布式系统中常见问题及解决方案
redis·python·fastapi·web·httpx·lock·asyncio
孟健1 天前
Karpathy 用 200 行纯 Python 从零实现 GPT:代码逐行解析
python
码路飞1 天前
写了个 AI 聊天页面,被 5 种流式格式折腾了一整天 😭
javascript·python
曲幽1 天前
FastAPI压力测试实战:Locust模拟真实用户并发及优化建议
python·fastapi·web·locust·asyncio·test·uvicorn·workers