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

如何修复AttributeError: module 'botocore.vendored.requests'无'exceptions'属性

解决AttributeError: module 'botocore.vendored.requests' has no attribute 'exceptions'

问题描述

发生异常:

AttributeError
module 'botocore.vendored.requests' has no attribute 'exceptions'
文件 "/Users/shrikantpadhy/Desktop/SWA-ENGINE/gateai-preplanning-engine/runner/main.py",第8行,在<module>中
import boto3
AttributeError: module 'botocore.vendored.requests' has no attribute 'exceptions'

环境配置:

  • python == 3.11.5
  • boto3==1.34.140
  • botocore==1.34.140

已尝试操作:重装boto3和botocore、更换Python版本,问题仍存在。

解决方法

1. 替换botocore.vendored.requests为标准requests库

botocore从较新版本开始,不再推荐使用内部封装的botocore.vendored.requests,且部分属性(如exceptions)已不再对外暴露。操作步骤:

  • 安装标准requests库(未安装时执行):
    pip install requests
    
  • 遍历代码中所有引用botocore.vendored.requests的位置,替换为requests。示例:
    原代码:
    from botocore.vendored.requests.exceptions import RequestException
    
    替换后:
    from requests.exceptions import RequestException
    

2. 锁定兼容版本(临时方案)

如果暂时无法修改代码,可以尝试降级到仍保留botocore.vendored.requests.exceptions的旧版本:

pip install boto3==1.29.0 botocore==1.32.0

3. 排查隐式依赖

部分第三方库可能会隐式引用botocore.vendored.requests,可通过以下命令排查:

pip freeze | xargs grep -l "botocore.vendored.requests"

找到对应依赖包后,优先更新到修复该问题的版本,或联系包作者处理。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.21 12:05:03