TensorFlow version
check TensorFlow version
TensorFlow installation
machine learning
software version troubleshooting

How do I find out the version of TensorFlow on my computer?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

When TensorFlow behaves differently across machines, the first thing to confirm is the exact version running in the environment that actually executes your code. The hard part is usually not printing the version string. It is making sure you are checking the right Python interpreter, notebook kernel, or virtual environment.

Confirm Which Python You Are Using

Before asking TensorFlow for anything, confirm which interpreter is active. This matters because a system Python, a virtual environment, a Conda environment, and a Jupyter kernel can all point at different installations.

bash
python3 -c "import sys; print(sys.executable)"
python3 -V

If you use a virtual environment, activate it first and then repeat the check:

bash
source .venv/bin/activate
python -c "import sys; print(sys.executable)"
python -V

For Conda users, the same principle applies:

bash
conda activate ml-env
python -c "import sys; print(sys.executable)"

If you skip this step, you can easily end up checking one Python installation while your editor or notebook is using another.

Query TensorFlow Through the Active Interpreter

Once you know which interpreter is active, ask that interpreter for package metadata.

bash
python -m pip show tensorflow

That output usually includes the installed version and the package location. You can also list related packages:

bash
python -m pip list | grep -i tensorflow

Using python -m pip instead of plain pip is important. It ties the package query to the same interpreter you just verified, which avoids a lot of false assumptions.

Check the Version from Inside Python

The most reliable answer is to import TensorFlow in the same runtime that executes your code and print tf.__version__.

python
1import sys
2import tensorflow as tf
3
4print("Python executable:", sys.executable)
5print("TensorFlow version:", tf.__version__)

This is the check that matters most when debugging real behavior. If pip show and tf.__version__ disagree, you almost certainly have an environment mismatch.

Inspect Build and Device Details Too

Sometimes the version string alone is not enough. Two machines can run the same TensorFlow version but behave differently because one build sees a GPU and the other does not.

python
1import tensorflow as tf
2
3print("TensorFlow:", tf.__version__)
4print("Built with CUDA:", tf.test.is_built_with_cuda())
5print("CPU devices:", tf.config.list_physical_devices("CPU"))
6print("GPU devices:", tf.config.list_physical_devices("GPU"))

This is especially useful when someone says "we have the same TensorFlow version" but one environment is CPU-only or has a different accelerator setup.

You can also inspect more build metadata:

python
1import tensorflow as tf
2
3for key, value in sorted(tf.sysconfig.get_build_info().items()):
4    print(key, value)

Jupyter and IDEs Need Separate Verification

Notebook kernels are a common source of confusion. Your terminal environment may be correct while the notebook is running a completely different interpreter.

Add a diagnostic cell like this:

python
1import sys
2import tensorflow as tf
3
4print(sys.executable)
5print(tf.__version__)

If the interpreter path is not the one you expected, fix the kernel configuration instead of reinstalling packages blindly.

The same goes for IDEs such as VS Code or PyCharm. Check the selected interpreter in the IDE and compare it with the value printed by sys.executable.

Keep a Small Diagnostic Script

For team debugging, it helps to keep one reproducible environment check instead of trading screenshots and partial terminal output.

python
1# tf_check.py
2import sys
3
4try:
5    import tensorflow as tf
6except Exception as exc:
7    print("TensorFlow import failed:", exc)
8    print("Python executable:", sys.executable)
9    raise
10
11print("Python executable:", sys.executable)
12print("Python version:", sys.version)
13print("TensorFlow version:", tf.__version__)
14print("GPUs:", tf.config.list_physical_devices("GPU"))

Running this script in CI, notebooks, and local shells produces a consistent baseline for comparison.

Common Pitfalls

The most common mistake is using pip show tensorflow from one interpreter and then running TensorFlow code with another. Always keep the package query tied to the interpreter with python -m pip.

Another issue is assuming the terminal and notebook are the same environment. Notebook kernels often lag behind environment changes, so sys.executable should be checked in both places.

Developers also focus only on the version string when the real difference is build configuration or device visibility. The same version number does not guarantee the same runtime capabilities.

Summary

  • Confirm the active Python interpreter before checking TensorFlow.
  • Use python -m pip show tensorflow to inspect the package in the correct environment.
  • Print tf.__version__ from the runtime that actually executes your code.
  • Check device visibility and build information when GPU support matters.
  • Verify notebooks and IDEs separately because they may use different interpreters.

Course illustration
Course illustration

All Rights Reserved.