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