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

Ubuntu14.04安装Python2的python-dev等依赖包报错,求修复方案

Fixing "Unable to correct problems, you have held broken packages" when installing python-dev on Ubuntu 14.04

Let's work through this step by step—this error usually pops up due to outdated package caches, unconfigured packages, held packages, or since Ubuntu 14.04 is end-of-life (EOL), your package sources might be pointing to retired servers. Here's how to fix it:

Step 1: Refresh package lists and upgrade existing packages

First, make sure your system's package info is up to date and all installed packages are current:

sudo apt-get update
sudo apt-get upgrade

This ensures you're pulling the latest available versions (for 14.04's archived repos) and clears up any outdated cache that might be causing dependency mismatches.

Step 2: Fix broken dependencies and unconfigured packages

Run these commands to automatically repair missing dependencies and finish setting up any half-installed packages:

sudo apt-get -f install
sudo dpkg --configure -a

The -f flag tells apt to "fix" broken dependencies, while dpkg --configure -a resolves any packages that were interrupted during installation.

Step 3: Check for held packages

The error mentions "held broken packages"—let's see if any packages are locked from updating:

dpkg --get-selections | grep hold

If you see output like libpython-dev hold or python2.7-dev hold, unlock them with:

sudo apt-mark unhold libpython-dev python2.7-dev

Held packages can block dependency resolution, so unlocking them often fixes the issue.

Step 4: Install dependencies directly, then your target packages

If the above steps don't work, try installing the missing dependencies first, then your original packages:

# Install the missing dependencies first
sudo apt-get install python2.7-dev libpython-dev
# Now install your desired packages
sudo apt-get install python-dev libxml2-dev libxslt-dev

This forces apt to resolve the dependency chain for the required packages before installing the ones you need.

Step 5: Update your package sources (critical for Ubuntu 14.04 EOL)

Since Ubuntu 14.04 is no longer supported, the default package sources might be offline. Replace your /etc/apt/sources.list entries with the old releases archive:

  1. Backup your current sources list first:
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
    
  2. Edit the sources list with your favorite editor (e.g., nano):
    sudo nano /etc/apt/sources.list
    
  3. Replace all instances of http://archive.ubuntu.com/ubuntu/ or http://us.archive.ubuntu.com/ubuntu/ with http://old-releases.ubuntu.com/ubuntu/
  4. Save and exit (in nano: Ctrl+O, Enter, Ctrl+X)
  5. Run sudo apt-get update again, then try installing the packages once more.

Why this happens

Ubuntu 14.04 reached end-of-life in April 2021, so official repositories are no longer maintained. This means dependency packages might be missing from your current sources, or your system has leftover broken packages from interrupted installs or outdated cache.

内容的提问来源于stack exchange,提问作者ChikChak

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:18:05