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

已安装sagemaker仍报错ModuleNotFoundError: No module named 'sagemaker.huggingface'

问题成因

通过conda install sagemaker安装的SageMaker SDK包不包含huggingface子模块。Conda渠道提供的SageMaker包属于精简版本,未集成Hugging Face相关扩展模块,而pip官方源的SageMaker SDK才完整包含该子模块。

解决步骤
  1. 卸载当前conda环境中的sagemaker包:
conda remove sagemaker -y
  1. 使用pip重新安装指定版本的完整SageMaker SDK:
pip install sagemaker==2.213.0
  1. 验证子模块是否存在:
    运行以下代码确认:
import sagemaker
if 'huggingface' in dir(sagemaker):
    print('The huggingface submodule is included in this version of sagemaker.')
else:
    print('The huggingface submodule is not included in this version of sagemaker.')

此时应输出包含子模块的提示。
4. 重新导入模块:

from sagemaker.huggingface import HuggingFace
额外说明

若使用SageMaker Studio的SageMaker Distribution环境,可直接使用预安装的完整SageMaker SDK,无需自行创建conda环境。若必须使用自定义conda环境,务必通过pip安装sagemaker而非conda渠道。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.27 12:03:17