verify version tensorflow code example

Example 1: check tensorflow version

import tensorflow as tf
tf.__version__

Example 2: tf version

python -c 'import tensorflow as tf; print(tf.__version__)'  # for Python 2
python3 -c 'import tensorflow as tf; print(tf.__version__)'  # for Python 3

Example 3: how to know version of tensorflow in linux command line

python -c 'import tensorflow as tf; print(tf.__version__)'  # for Python 2 on linux
python3 -c 'import tensorflow as tf; print(tf.__version__)'  # for Python 3 on linux

Example 4: how to check tensorflow version

pip show tensorflow