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

Ubuntu系统下Python 3.10的pip无法正常使用问题求助

Fixing "ImportError: cannot import name 'html5lib' from 'pip._vendor'" with Python 3.10 on Ubuntu

Hey there! Let's work through this pip error you're hitting. The core issue here is that the system-provided pip isn't properly compatible with your Python 3.10 installation, or the pip package itself has become corrupted—especially the bundled dependencies like html5lib that pip relies on in its pip._vendor directory. Installing python3.10-html5lib didn't help because that's a system-level library, not the bundled version pip expects to use internally.

Here are the steps to resolve this:

  • First, remove the conflicting system-wide pip package to eliminate version mismatches:

    sudo apt remove --purge python3-pip
    

    This clears out the problematic pip tied to Ubuntu's default Python version, which was causing the conflict with your Python 3.10 setup.

  • Reinstall pip specifically for Python 3.10 using Python's built-in ensurepip tool:

    python3.10 -m ensurepip --upgrade
    

    This command installs the official, version-matched pip for Python 3.10 and upgrades it to the latest stable release, ensuring all bundled dependencies (like html5lib) are intact.

  • If the above step doesn't work, try installing the Python 3.10-specific pip package via apt:

    sudo apt install python3.10-pip
    

    This pulls a pre-packaged pip tailored for Python 3.10 directly from Ubuntu's repositories.

  • Finish by upgrading pip to the latest version to lock in all fixes:

    python3.10 -m pip install --upgrade pip
    

Once you've completed these steps, test your original installation command again:

python3.10 -m pip install <library name>

This should resolve the html5lib import error, as you'll now be using a pip version fully aligned with Python 3.10 and equipped with all its required internal dependencies.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 18:02:36