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

升级最新Python后用pip安装包遇SSL证书错误求助

Fixing pip Installation & SSL Certificate Errors After Upgrading Python

Hey there, let's break down what's happening with your pip issues and fix them step by step. From your error traceback, it looks like you're accidentally using Python 2.7's pip even though you upgraded to the latest Python version—plus the old SSL certificate error is lingering. Here's how to tackle both problems:

1. Make Sure You're Using the Correct Pip (For Your New Python Version)

Your error log shows pip is running from Python 2.7's directory (/Library/Frameworks/Python.framework/Versions/2.7/...), which means your terminal is still prioritizing the old Python installation. Let's fix that:

  • First, verify which Python/pip versions you're currently using:
    python --version
    pip --version
    
  • If they show Python 2.7, switch to your new Python's pip (usually pip3 for Python 3, or a version-specific alias like pip3.11):
    python3 --version
    pip3 --version
    
  • To make this the default, add aliases to your shell config file (e.g., ~/.zshrc for Zsh, ~/.bash_profile for Bash):
    alias python='python3'
    alias pip='pip3'
    
    Save the file, then restart your terminal or run source ~/.zshrc (replace with your config path) to apply the changes.

2. Resolve the SSL Certificate Error

SSL issues usually stem from outdated pip versions or missing system certificates. Here's how to fix them:

  • First, upgrade pip to the latest version (this fixes most TLS/SSL compatibility issues):
    pip3 install --upgrade pip
    
  • If you still get SSL errors when installing packages, bypass certificate checks temporarily (note: this is insecure for untrusted sources, only use for PyPI):
    pip3 install your-package-name --trusted-host pypi.org --trusted-host files.pythonhosted.org
    
  • If you must use Python 2.7's pip (strongly discouraged—Python 2 is end-of-life), install the last compatible pip version and use the trusted host flag:
    pip2 install --upgrade pip==20.3.4
    pip2 install your-package-name --trusted-host pypi.org --trusted-host files.pythonhosted.org
    

3. Fix System Root Certificate Issues (If All Else Fails)

Sometimes SSL errors happen because your system's root certificates are outdated or missing:

  • On macOS, update your root certificates via Homebrew:
    brew install ca-certificates
    
  • Then tell pip to use the updated certificates when installing packages:
    pip3 install your-package-name --cert /usr/local/etc/openssl/cert.pem
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 10:01:41