Ubuntu 16.04 下 Python/PIP 环境损坏,无法使用 pip3 安装软件求助
Hey there, let's fix your broken pip3 environment on Ubuntu 16.04 step by step. The error you're seeing typically stems from either corrupted system pip files or a conflict between the apt-managed pip and a manually installed version in /usr/local/bin. Here's how to get everything back on track:
Step 1: 彻底清理并重新安装系统pip3
First, we'll purge the existing system pip3 package completely (this removes all corrupted files and configurations):
sudo apt-get purge --auto-remove python3-pip
Then reinstall the fresh, official version from Ubuntu's repos:
sudo apt-get install python3-pip
Step 2: 解决路径冲突
Run this command to check which pip3 your system is using:
which pip3
If the output is /usr/local/bin/pip3 instead of /usr/bin/pip3, that's likely the culprit—this is a leftover from a manual pip install that's conflicting with the system version. Delete it with:
sudo rm /usr/local/bin/pip3
Now your system should default to the correct apt-managed pip3 at /usr/bin/pip3.
Step 3: 升级pip到兼容版本
Ubuntu 16.04 ships with Python 3.5, which isn't supported by newer pip versions. We'll upgrade pip to the latest version that works with Python 3.5:
pip3 install --user --upgrade pip==9.0.3
Using the --user flag ensures this installs to your user directory instead of messing with system files.
Step 4: 安装OCRmyPDF及其依赖
OCRmyPDF relies on some system-level tools that aren't installed by default. Install them first:
sudo apt-get install ghostscript tesseract-ocr
Now you can install OCRmyPDF successfully:
pip3 install --user ocrmypdf
Step 5: 验证修复结果
Check if pip3 is working again:
pip3 --version
And confirm OCRmyPDF installed correctly:
ocrmypdf --version
内容的提问来源于stack exchange,提问作者enigma969

