Home > Blockchain >  Cannot import tensorflow_text
Cannot import tensorflow_text

Time:07-14

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.

NotFoundError: 
/usr/local/lib/python3.7/distpackages/tensorflow_text/python/ops/_sentencepiece_tokenizer.so: 
undefined symbol: _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev

CodePudding user response:

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 
  • Related