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

macOS安装Locust失败:gevent编译wheel报错求助

解决macOS Monterey安装Locust时gevent编译失败的问题

核心解决步骤

  • 安装Xcode命令行工具并确认许可
    执行以下命令安装工具:

    xcode-select --install
    

    安装完成后,必须接受Xcode许可协议,否则编译器会报错:

    sudo xcodebuild -license accept
    
  • 安装gevent编译依赖的libevent库
    使用Homebrew安装libevent(若未安装Homebrew,需先完成Homebrew安装):

    brew install libevent
    
  • 设置环境变量让编译器找到依赖
    执行以下命令导出环境变量,确保gevent编译时能定位到libevent:

    export CFLAGS="-I$(brew --prefix libevent)/include"
    export LDFLAGS="-L$(brew --prefix libevent)/lib"
    
  • 升级构建工具并重新安装Locust
    先升级setuptools和wheel,确保支持pyproject.toml的构建:

    pip3 install --upgrade setuptools wheel
    

    之后重新执行安装命令:

    # 使用pip3安装
    pip3 install -U locust
    # 或使用pipenv安装
    pipenv install locust
    

备选方案(无需编译)

如果上述步骤仍无法解决,可使用conda安装预编译版本的Locust,避免本地编译:

conda install -c conda-forge locust

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 03:15:36