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

如何解决pip安装失败问题?Windows11+Python3.11.5环境报错

问题描述

系统环境:Windows 11,Python 3.11.5
执行pip install numpy时出现如下报错,且安装任何Python包都会触发相同错误:

C:\Users\awmvi>pip install numpy
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))': /simple/numpy/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))': /simple/numpy/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))': /simple/numpy/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))': /simple/numpy/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))': /simple/numpy/
ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
ERROR: No matching distribution found for numpy
解决方法
  • 检查并清空pip代理配置
    连接中断错误大概率和代理设置有关。先查看当前代理:

    pip config get global.proxy
    

    如果返回代理地址,执行以下命令清空:

    pip config unset global.proxy
    

    之后重新尝试安装。

  • 切换国内PyPI镜像源
    默认PyPI源在国内网络下易不稳定,可临时指定国内镜像安装:

    pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
    

    若临时生效,可配置永久使用国内源:

    1. 在用户目录(如C:\Users\awmvi)下创建pip文件夹
    2. 新建pip.ini文件,写入:
      [global]
      index-url = https://pypi.tuna.tsinghua.edu.cn/simple
      
  • 修复或重装pip
    pip本身损坏也会引发这类问题,执行以下命令重装pip:

    python -m ensurepip --upgrade
    

    或者用官方脚本重装:

    curl https://bootstrap.pypa.io/get-pip.py | python
    
  • 排查防火墙/杀毒软件拦截
    临时关闭系统防火墙和杀毒软件,再尝试安装。如果问题解决,将pip程序添加到信任列表。

  • 验证Python环境变量
    确保Python和pip的路径已加入系统环境变量:

    1. 右键「此电脑」→「属性」→「高级系统设置」→「环境变量」
    2. 在系统变量的Path中,确认包含Python安装目录(如C:\Python311)和Scripts目录(如C:\Python311\Scripts)
    3. 未添加则手动补充,之后重启命令提示符。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 07:23:24