error: externally-managed-environment
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied
ERROR: No matching distribution found for package==1.0
pip install can fail for many reasons. Here are the most common ones.
Fix 1: Externally Managed Environment
# ❌ System Python is protected (Ubuntu 23.04+, Fedora 38+)
pip install requests # 💥 externally-managed-environment
# ✅ Use a virtual environment
python3 -m venv venv
source venv/bin/activate
pip install requests
Fix 2: Permission Denied
# ❌ Don't use sudo pip
sudo pip install requests # Bad practice
# ✅ Use --user flag
pip install --user requests
# ✅ Or better: use a virtual environment
python3 -m venv venv
source venv/bin/activate
pip install requests
Fix 3: No Matching Distribution
# ❌ Package doesn't exist or wrong Python version
pip install nonexistent-package
# ✅ Check the correct package name on PyPI
pip install Pillow # Not "pillow" or "PIL"
# Check your Python version
python3 --version
# Some packages don't support all Python versions
Fix 4: Version Conflict
# ❌ Two packages need different versions of a dependency
pip install package-a package-b # 💥 Conflict
# ✅ Check what's conflicting
pip check
# ✅ Try installing with --upgrade
pip install --upgrade package-a package-b
Fix 5: SSL Certificate Error
# ❌ Corporate proxy or outdated certificates
pip install requests # 💥 SSL: CERTIFICATE_VERIFY_FAILED
# ✅ Upgrade pip and certifi
pip install --upgrade pip certifi
# ✅ Temporary workaround (not recommended)
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org requests
Fix 6: Slow or Timeout
# ❌ PyPI is slow or blocked
pip install requests # 💥 Timeout
# ✅ Use a mirror
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests
# ✅ Increase timeout
pip install --timeout 120 requests