Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow-text does not import

I am trying to import tensorflow text into google colab, but it is not working. I first used the cell

!pip install tensorflow-text

and got a message saying that it had been installed correctly, however when I run the cell:

import tensorflow_text as text

I get the error


---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 import tensorflow_text as text

ModuleNotFoundError: No module named 'tensorflow_text'

How do i solve this? I cannot understand why colab does not register it as a library. I have also tried re-hosting the session on my computer and installing tf text on there, but it still gives the module not found error. Does anyone know a solution?

like image 290
Mercury Avatar asked Sep 11 '26 05:09

Mercury


1 Answers

I ran into this same problem. I had two issues first I overlooked that one small line at the very top, above the imports, of the Tensorflow code example. Silly mistake, but it happens... Second, it appears Google Colab currently has some compatibility issues with certain versions of tensorflow-text. I resolved that issue by requiring it to load v2.8.

Solution: Install tensorflow-text version 2.8

!pip3 install --quiet "tensorflow-text==2.8.*"
like image 158
Narm Avatar answered Sep 13 '26 18:09

Narm