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

安装discord.py时aiohttp编译wheel失败,求解决方法

解决pip install discord.py编译aiohttp失败的问题

1. 补全编译依赖

aiohttp编译需要C语言环境和系统依赖库,不同系统处理方式如下:

  • Windows:安装Visual Studio Build Tools,勾选「C开发工具」和「Windows SDK」组件;或者直接安装对应版本的Microsoft Visual C可再发行组件包。
  • Linux(Debian/Ubuntu):执行以下命令:
    sudo apt-get install build-essential python3-dev libssl-dev libffi-dev
    
  • macOS:先安装Xcode命令行工具:
    xcode-select --install
    
    再通过Homebrew安装openssl:
    brew install openssl
    

2. 升级pip与编译工具

虚拟环境内的pip版本过低可能无法正常处理pyproject.toml,先执行升级:

pip install --upgrade pip setuptools wheel

3. 直接安装预编译的aiohttp包

如果编译仍失败,可绕开编译环节,直接安装现成的预编译wheel包:

  • 先确认当前虚拟环境的Python版本和系统架构:
    python -c "import sys; print(sys.version_info[:2]); print(sys.platform)"
    
  • 找到对应版本的aiohttp wheel文件(比如Python3.8+Windows x64对应aiohttp-*.cp38-win_amd64.whl),下载后用pip install 文件名.whl安装,再执行pip install discord.py。

4. 确认虚拟环境激活状态

确保安装时已正确激活Miniconda创建的Python3.8虚拟环境:

  • Windows:conda activate 你的虚拟环境名
  • Linux/macOS:source activate 你的虚拟环境名
    激活后执行python --version,确认版本为3.8.x再进行安装操作。

5. 更换PyPI镜像源

若因网络问题导致依赖下载失败,可切换到国内镜像源尝试:

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

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 09:00:56