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

Windows10+VS Code环境下安装Django失败,求解决方案

解决Django安装失败的问题

问题场景

Windows10系统,在VS Code中使用%pip install Django,或在Anaconda中安装Django时,出现以下错误:

Could not fetch URL https://pypi.org/simple/django/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/django/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))) - skippingNote: you may need to restart the kernel to use updated packages.

Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))) - skipping
WARNING: Ignoring invalid distribution -orch (d:\program files\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -cipy (d:\program files\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -orch (d:\program files\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -cipy (d:\program files\anaconda\lib\site-packages)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/django/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/django/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/django/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/django/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/django/
ERROR: Could not find a version that satisfies the requirement Django (from versions: none)
ERROR: No matching distribution found for Django
WARNING: Ignoring invalid distribution -orch (d:\program files\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -cipy (d:\program files\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -orch (d:\program files\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -cipy (d:\program files\anaconda\lib\site-packages)
WARNING: There was an error checking the latest version of pip.

解决方案

1. 修复无效的Python包

错误中的Ignoring invalid distribution -orch和-cipy是包目录命名异常导致的(大概率是torch和scipy安装残留),执行以下命令强制重装修复:

  • 打开对应环境的终端(VS Code终端或Anaconda Prompt),运行:
    pip install --force-reinstall torch scipy
    

2. 解决SSL证书连接问题

核心错误是无法验证PyPI的SSL证书,可通过以下两种方式解决:

  • 方法一:使用国内镜像源安装
    直接通过国内镜像绕开SSL验证问题,执行:
    # pip安装Django
    pip install django -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
    # 或Anaconda中用conda安装
    conda install django -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    
  • 方法二:修复系统SSL证书
    • 检查并安装Windows系统的根证书更新(通过Windows更新功能获取,或手动安装微软官方根证书包)
    • 重置pip的SSL配置,执行:
      pip config unset global.cert
      

3. 检查网络代理设置

如果使用了代理,可能导致SSL连接异常:

  • 临时关闭系统代理或VPN后重试安装
  • 重置pip的代理配置:
    pip config unset global.proxy
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 15:57:11