{"record":{"id":"6569d5442da8f4fd","repo":"keras-team/keras","slug":"layer-textvectorization-requires-tensorflow-insta","errorCode":null,"errorMessage":"Layer TextVectorization requires TensorFlow. Install it via `pip install tensorflow`.","messagePattern":"Layer TextVectorization requires TensorFlow\\. Install it via `pip install tensorflow`\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/text_vectorization.py","lineNumber":230,"sourceCode":"    def __init__(\n        self,\n        max_tokens=None,\n        standardize=\"lower_and_strip_punctuation\",\n        split=\"whitespace\",\n        ngrams=None,\n        output_mode=\"int\",\n        output_sequence_length=None,\n        pad_to_max_tokens=False,\n        vocabulary=None,\n        idf_weights=None,\n        sparse=False,\n        ragged=False,\n        encoding=\"utf-8\",\n        name=None,\n        **kwargs,\n    ):\n        if not tf.available:\n            raise ImportError(\n                \"Layer TextVectorization requires TensorFlow. \"\n                \"Install it via `pip install tensorflow`.\"\n            )\n        if sparse and backend.backend() != \"tensorflow\":\n            raise ValueError(\n                \"`sparse=True` can only be used with the TensorFlow backend.\"\n            )\n        if ragged and backend.backend() != \"tensorflow\":\n            raise ValueError(\n                \"`ragged=True` can only be used with the TensorFlow backend.\"\n            )\n\n        # 'standardize' must be one of\n        # (None, \"lower_and_strip_punctuation\", \"lower\", \"strip_punctuation\",\n        # callable)\n        argument_validation.validate_string_arg(\n            standardize,\n            allowable_strings=(","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/text_vectorization.py#L212-L248","documentation":"ImportError sentinel raised at the very top of TextVectorization.__init__: keras.src.backend.tensorflow reports TensorFlow is not installed/importable, and this layer's string tokenizer and lookup ops are TensorFlow-only. It fires on construction, before any argument validation.","triggerScenarios":"Thrown at keras/src/layers/preprocessing/text_vectorization.py:230 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Install TensorFlow: pip install tensorflow","Precompute vectorization (e.g. with a pure-Python tokenizer + StringLookup alternative) if TensorFlow cannot be installed"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}