Ubuntu系统下Python 3.10的pip无法正常使用问题求助
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-pipThis 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
ensurepiptool:python3.10 -m ensurepip --upgradeThis 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-pipThis 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

