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

使用Rasa训练聊天机器人遇TensorFlow导入错误求助

解决Rasa训练时TensorFlow resource_loader导入错误的方案

执行rasa train时出现如下错误:

from tensorflow._api.v2.compat.v1 import resource_loader
ImportError: cannot import name 'resource_loader' from partially initialized module 'tensorflow._api.v2.compat.v1'

这个问题是TensorFlow版本与Rasa版本不兼容导致的,调整TensorFlow版本即可解决,步骤如下:

  • 查看当前Rasa版本:执行命令 rasa --version
  • 根据Rasa版本匹配对应TensorFlow版本:
    • Rasa 3.x系列适配TensorFlow 2.8.x~2.9.x版本
    • Rasa 2.x系列适配TensorFlow 2.5.x左右版本(避免使用过高版本)
  • 卸载当前TensorFlow:pip uninstall tensorflow -y
  • 安装指定兼容版本,示例:pip install tensorflow==2.8.4
  • 重新运行rasa train验证修复效果

如果不想手动匹配版本,也可以执行pip install rasa[full],该命令会自动安装Rasa及所有兼容的依赖包。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 19:19:52