keras-team/keras · error · ImportError
Layer TextVectorization requires TensorFlow. Install it via
Error message
Layer TextVectorization requires TensorFlow. Install it via `pip install tensorflow`.
What it means
Error "Layer TextVectorization requires TensorFlow. Install it via `pip install tensorflow`." thrown in keras-team/keras.
Source
Thrown at keras/src/layers/preprocessing/text_vectorization.py:230
def __init__(
self,
max_tokens=None,
standardize="lower_and_strip_punctuation",
split="whitespace",
ngrams=None,
output_mode="int",
output_sequence_length=None,
pad_to_max_tokens=False,
vocabulary=None,
idf_weights=None,
sparse=False,
ragged=False,
encoding="utf-8",
name=None,
**kwargs,
):
if not tf.available:
raise ImportError(
"Layer TextVectorization requires TensorFlow. "
"Install it via `pip install tensorflow`."
)
if sparse and backend.backend() != "tensorflow":
raise ValueError(
"`sparse=True` can only be used with the TensorFlow backend."
)
if ragged and backend.backend() != "tensorflow":
raise ValueError(
"`ragged=True` can only be used with the TensorFlow backend."
)
# 'standardize' must be one of
# (None, "lower_and_strip_punctuation", "lower", "strip_punctuation",
# callable)
argument_validation.validate_string_arg(
standardize,
allowable_strings=(View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/preprocessing/text_vectorization.py:230 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/6569d5442da8f4fd.
Report an issue: GitHub.