Cannot import tensorflow_text


I have problem with importing tensorflow_text I tried importing like below two methods but none of them worked

import tensorflow_text as text
import tensorflow_text as tf_text

My tensorflow version is 2.9.1 and python version is Python 3.7.13. I tried installing tensorflow_text using below two methods but none of them is working.

!pip install tensorflow-text
!pip install -U tensorflow-text==2.9.0

I am using colab, I also tried reinstalling tensorflow but it still generates below error.

undefined symbol: _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev


First, install tensorflow-text version 2.8.* like below:

!pip install -q -U "tensorflow-text==2.8.*"

Then import tensorflow-text like below:

import tensorflow_text as text 

Answered By – I'mahdi

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published