Skip to main content

How to Check Which Version of TensorFlow Is Installed

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

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​

Syntax
tf.__version__
tf.version.<detail>
PartWhat it means
tfTensorFlow, 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​

versions.py
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)

The versions.py script in a macOS-style code window: it imports tensorflow as tf and prints tf.version, tf.version.VERSION, tf.version.GIT_VERSION and tf.version.COMPILER_VERSION, each with a label.

Step 2: Run It​

Terminal
uv run python versions.py
Output
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)

The terminal after uv run python versions.py: TensorFlow 2.22.0, the same version from tf.version, the Git commit v2.22.0-rc1-2-gb3c3b32d1f3, and Apple LLVM 16.0.0 as the compiler.

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:

Terminal
uv pip show tensorflow
Output
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

The terminal after uv pip show tensorflow: Name tensorflow, Version 2.22.0, its location in the project's .venv, the packages it requires, and 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​

MistakeWhat happensDo this instead
Running pip3 show tensorflow with your computer's own pipIt looks at a different Python, not the project's .venv: here it printed WARNING: Package(s) not found: tensorflowUse uv pip show tensorflow in the project folder
Printing tf.version without a detailIt 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 versionKeras has its own version: 3.15.1 hereCheck 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​