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

求助:在Google Colab导入tensorflow_text(用于BERT)时遇未定义符号错误

解决tensorflow_text导入报错(NotFoundError: undefined symbol)

核心原因

这个错误是tensorflow与tensorflow_text版本不兼容导致的——tensorflow_text的底层编译依赖特定版本的TensorFlow API,版本不匹配时会出现符号找不到的问题。

解决步骤

  1. 卸载当前的tensorflow和tensorflow_text
    pip uninstall -y tensorflow tensorflow_text
    
  2. 安装版本完全匹配的组合:
    tensorflow_text的版本必须和TensorFlow主版本、次版本完全对应,比如:
    • TensorFlow 2.15.x → tensorflow_text 2.15.x
    • TensorFlow 2.14.x → tensorflow_text 2.14.x
      以2.15版本为例,执行安装命令:
    pip install tensorflow==2.15.0 tensorflow_text==2.15.0
    
  3. 验证安装结果:
    import tensorflow as tf
    import tensorflow_text as text
    print(tf.__version__)
    print(text.__version__)
    
    确保两个版本号完全一致即可。

额外注意事项

  • 如果使用conda环境,建议全程用conda安装,避免依赖冲突:
    conda uninstall -y tensorflow tensorflow-text
    conda install tensorflow=2.15.0 tensorflow-text=2.15.0
    
  • 不要混合使用pip和conda安装TensorFlow相关包,容易导致环境混乱。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 05:05:19