安装discord.py时触发subprocess错误,寻求解决方案
解决Python 3.12安装discord.py时subprocess-exited-with-error错误
错误核心是Python 3.12移除了_longobject.ob_digit内部API,而你安装的discord.py依赖的旧版aiohttp未适配这个变动,导致编译aiohttp轮子失败。以下是具体解决办法:
方案1:降级Python到3.11(最稳定)
- 卸载当前Python 3.12,下载安装Python 3.11版本
- 执行安装命令:
py -3.11 -m pip install -U discord.py
方案2:安装适配Python 3.12的discord.py预发布版
discord.py的2.3.0及以上预发布版本已适配Python 3.12,执行以下命令:
py -3 -m pip install -U discord.py==2.3.0a
或者直接安装GitHub上的最新开发版:
py -3 -m pip install -U git+https://github.com/Rapptz/discord.py
方案3:先安装适配3.12的aiohttp版本
先安装支持Python 3.12的aiohttp测试版,再安装discord.py:
py -3 -m pip install -U aiohttp==3.9.0b0 py -3 -m pip install -U discord.py
前置准备:确保pip是最新版本
执行以下命令更新pip,避免版本兼容问题:
py -3 -m pip install -U pip
内容的提问来源于stack exchange,提问作者CheersFahFeers
相关产品推荐
相关产品推荐

