How to Check Which Version of TensorFlow Is Installed
Bug reports, tutorials and error messages all depend on the TensorFlow version, so knowing exactly which one a project uses is the first thing to check. TensorFlow tells you itself, in tf.__version__, and tf.version adds how it was built. This guide reads all of it from TensorFlow 2.22.0, then checks the version without starting Python.
Syntax
tf.__version__
tf.version.<detail>
| Part | What it means |
|---|---|
tf | TensorFlow, imported with import tensorflow as tf |
__version__ | The version number, as a string |
tf.version.<detail> | Build details: VERSION is the version again, GIT_VERSION the source code it was built from, and COMPILER_VERSION the compiler that built it |
The tf.version API page lists these constants: COMPILER_VERSION, GIT_VERSION, GRAPH_DEF_VERSION, GRAPH_DEF_VERSION_MIN_CONSUMER, GRAPH_DEF_VERSION_MIN_PRODUCER and VERSION.
The Example
A uv project, tf-check, with TensorFlow added by uv add tensorflow. A script prints the version and the build details.
Prerequisites
- A uv project with TensorFlow. This guide uses TensorFlow 2.22.0 on Python 3.14.10, with uv 0.13.10.
Step 1: Write the Script
import tensorflow as tf
print("TensorFlow:", tf.__version__)
print("Same, from tf.version:", tf.version.VERSION)
print("Git commit:", tf.version.GIT_VERSION)
print("Built with:", tf.version.COMPILER_VERSION)

Step 2: Run It
uv run python versions.py
TensorFlow: 2.22.0
Same, from tf.version: 2.22.0
Git commit: v2.22.0-rc1-2-gb3c3b32d1f3
Built with: Apple LLVM 16.0.0 (clang-1600.0.26.6)

2.22.0 is the version, from both places. GIT_VERSION names the exact source code the package was built from: two commits after the v2.22.0-rc1 tag. COMPILER_VERSION shows that the macOS package was built with Apple's compiler. The command works unchanged in PowerShell.
The first run in a new environment is slow while TensorFlow loads for the first time; this one took 40 seconds.
Step 3: Check It Without Importing TensorFlow
When you only need the number, ask uv. It reads the package's details from the project's environment, without starting TensorFlow:
uv pip show tensorflow
Name: tensorflow
Version: 2.22.0
Location: /Users/you/source/tf-check/.venv/lib/python3.14/site-packages
Requires: absl-py, astunparse, flatbuffers, gast, google-pasta, grpcio, h5py, keras, libclang, ml-dtypes, numpy, opt-einsum, packaging, protobuf, requests, six, termcolor, typing-extensions, wrapt
Required-by: tf-check

Version: 2.22.0 again, plus where the package lives and what it depends on. Required-by: tf-check is the project itself. How to Check the Installed Version of a Python Package with uv shows the other ways uv reports versions.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Running pip3 show tensorflow with your computer's own pip | It looks at a different Python, not the project's .venv: here it printed WARNING: Package(s) not found: tensorflow | Use uv pip show tensorflow in the project folder |
Printing tf.version without a detail | It prints the module, not a version: <module 'tensorflow._api.v2.version' from '…'> | Use tf.__version__ or tf.version.VERSION |
Checking keras.__version__ for TensorFlow's version | Keras has its own version: 3.15.1 here | Check tf.__version__ |
FAQ
Which line should a bug report include?
tf.__version__ plus tf.version.GIT_VERSION: together they say exactly which build you ran.
Why do TensorFlow and Keras have different versions?
They're separate packages. TensorFlow 2.22.0 installed Keras 3.15.1 with it, and each gets its own updates.
Conclusion
tf.__version__ and tf.version.VERSION both printed 2.22.0, GIT_VERSION named the source it was built from, and uv pip show tensorflow gave the same version without importing TensorFlow at all.
Additional Resources
- tf.version — the version constants.
- TensorFlow releases — every version and its release notes.
