I need to find which version of TensorFlow I have installed. I'm using Ubuntu 16.04 Long Term Support.
-
17To retreive the summary (incl. version of package) try: `pip show [package name]`, eg: `pip show tensorflow`, `pip show numpy` etc. – Sumax Jul 30 '19 at 12:30
-
28Simply `print(tf.__version__)` – Pe Dro Apr 16 '20 at 07:37
-
1Anyone knowing the difference between `tf.__version__` and `tf.version.VERSION`? My 0.12.0 installation doesn't support latter. – Jianyu Oct 05 '20 at 12:36
-
1relevant TensorFlow 2.x API docs (`tf.version.VERSION` is a v2.0 API): https://www.tensorflow.org/api_docs/python/tf/version – michael Jan 25 '21 at 00:43
19 Answers
This depends on how you installed TensorFlow. I am going to use the same headings used by TensorFlow's installation instructions to structure this answer.
Pip installation
Run:
python -c 'import tensorflow as tf; print(tf.__version__)' # for Python 2
python3 -c 'import tensorflow as tf; print(tf.__version__)' # for Python 3
Note that python
is symlinked to /usr/bin/python3
in some Linux distributions, so use python
instead of python3
in these cases.
pip list | grep tensorflow
for Python 2 or pip3 list | grep tensorflow
for Python 3 will also show the version of Tensorflow installed.
Virtualenv installation
Run:
python -c 'import tensorflow as tf; print(tf.__version__)' # for both Python 2 and Python 3
pip list | grep tensorflow
will also show the version of Tensorflow installed.
For example, I have installed TensorFlow 0.9.0 in a virtualenv
for Python 3. So, I get:
$ python -c 'import tensorflow as tf; print(tf.__version__)'
0.9.0
$ pip list | grep tensorflow
tensorflow (0.9.0)

- 7,005
- 4
- 30
- 36
-
4and if you are building from source, your version is commit hash from `git rev-parse HEAD` – Yaroslav Bulatov Jul 26 '16 at 04:53
-
6Got ```'module' object has no attribute '__version__'``` when ```python -c 'import tensorflow as tf; print(tf.__version__)'``` – user3768495 Dec 09 '16 at 02:53
-
@user3768495 Hmm, interesting, let me test that later. Meanwhile, the `pip list` way should work if you used `pip` for installation. – edwinksl Dec 09 '16 at 03:14
-
```pip list | grep tensorflow``` worked tho. My version is 0.5.0. Maybe it's toooo old to have the '__version__' attribute? – user3768495 Dec 09 '16 at 03:26
-
1@user3768495 If you installed Tensorflow with VirtualEnv you need to activate the environment and that must be done for any new console you open (source ~/tensorflow/bin/activate). Once you do that you can retrieve your tensorflow version (pip list | grep tensorflow) – Nestor Urquiza Mar 18 '18 at 14:29
-
-
8for Windows CMD you need to use double quote `"` instead of `'`: `python3 -c "import tensorflow as tf; print(tf.__version__)"` – user924 Dec 15 '18 at 19:46
-
I tried both pip and python, i.e. `pip list | grep tensorflow` and `python -c 'import tensorflow as tf; print(tf.__version__)'`. But these two commands give me two different outputs. For pip, it shows `tensorflow 1.12.0`. For python, it shows `1.10.0`. Right before using two two commands to check the version, I used `pip install tensorflow=1.10.0`. Before running this install command, I believe my system was installed with 1.12.0. But, how come after running this install command, could these two version checking commands give different answers? Or, did I miss anything there? – Jack Chan Jan 24 '19 at 02:12
-
`py -3 -c 'import tensorflow as tf; print(tf.__version__)'` worked in my case. – Jithin Jude Apr 15 '19 at 06:42
-
2[jalal@goku examples]$ python -c 'import tensorflow as tf; print(tf.__version__)' Traceback (most recent call last): File "
", line 1, in – Mona Jalal Dec 08 '19 at 01:41AttributeError: module 'tensorflow' has no attribute '__version__'
Almost every normal package in python assigns the variable .__version__
to the current version. So if you want to find the version of some package you can do the following
import a
a.__version__
For tensorflow it will be
import tensorflow as tf
tf.version.VERSION
For old versions of tensorflow (below 0.10), use tf.__version__

- 1
- 1

- 214,103
- 147
- 703
- 753
-
11tf.VERSION doesn't work for TF2.0. However, tf.__version__ works fine. – apatsekin Oct 09 '19 at 22:38
-
1
-
I've installed 'tensorflow-cpu==2.4.1' on my venv and opened jupyter notebook after activating venv. When I do "!pip freeze" it show tensorflow-cpu==2.4.1 correctly however when I run tf.__version__ it tells me I have version 2.7.0. – haneulkim May 12 '22 at 06:03
-
looks like even for TF2.0 both works for me, tf.__version__ as well as tf.version.VERSION – Debjyoti Banerjee Sep 02 '22 at 07:05
If you have installed via pip, just run the following
$ pip show tensorflow
Name: tensorflow
Version: 1.5.0
Summary: TensorFlow helps the tensors flow

- 3,623
- 1
- 25
- 14
-
2`pip show tensorflow-gpu` for GPU version. Better yet, just do `pip list | grep tensorflow`. – user1857492 Jun 28 '19 at 06:40
-
1
-
-
Fun fact: I just realized why this package is called tensorflow thanks to your answer! – Luca Clissa Sep 17 '22 at 05:46
-
1
-
print() with parentheses is a python3 thing, not necessary for python2. – David Skarbrevik Jul 05 '18 at 01:43
For python 3.6.2:
import tensorflow as tf
print(tf.version.VERSION)
If you're using anaconda distribution of Python,
$ conda list | grep tensorflow
tensorflow 1.0.0 py35_0 conda-forge
To check it using Jupyter Notebook (IPython Notebook)
In [1]: import tensorflow as tf
In [2]: tf.__version__
Out[2]: '1.0.0'

- 57,311
- 13
- 161
- 150
For knowing any version of the python library then if your library is installed using the pip then use the following command.
pip show tensorflow
The Output of the above command will be shown below:-
Name: tensorflow
Version: 2.3.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /usr/local/lib/python3.6/dist-packages
Requires: astunparse, wheel, keras-preprocessing, gast, tensorflow-estimator, opt-einsum, tensorboard, protobuf, absl-py, six, wrapt, termcolor, numpy, grpcio, scipy, google-pasta, h5py
Required-by: fancyimpute

- 169
- 1
- 4
I installed the Tensorflow 0.12rc from source, and the following command gives me the version info:
python -c 'import tensorflow as tf; print(tf.__version__)' # for Python 2
python3 -c 'import tensorflow as tf; print(tf.__version__)' # for Python 3
The following figure shows the output:

- 858
- 2
- 11
- 23
To get more information about tensorflow and its options you can use below command:
>> import tensorflow as tf
>> help(tf)

- 18,390
- 23
- 91
- 111
-
1I get python3.6 -c 'import tensorflow as tf; help(tf)' Segmentation fault (core dumped) – John Jiang Aug 27 '18 at 05:52
On Latest TensorFlow release 1.14.0
tf.VERSION
is deprecated, instead of this use
tf.version.VERSION
ERROR:
WARNING: Logging before flag parsing goes to stderr.
The name tf.VERSION is deprecated. Please use tf.version.VERSION instead.

- 31,138
- 12
- 157
- 147
Easily get KERAS and TENSORFLOW version number --> Run this command in terminal:
[username@usrnm:~] python3
>>import keras; print(keras.__version__)
Using TensorFlow backend.
2.2.4
>>import tensorflow as tf; print(tf.__version__)
1.12.0

- 605
- 10
- 11
The tensorflow version can be checked either on terminal or console or in any IDE editer as well (like Spyder or Jupyter notebook, etc)
Simple command to check version:
(py36) C:\WINDOWS\system32>python
Python 3.6.8 |Anaconda custom (64-bit)
>>> import tensorflow as tf
>>> tf.__version__
'1.13.1'

- 340
- 2
- 6
Another variation, i guess :P
python3 -c 'print(__import__("tensorflow").__version__)'

- 1,727
- 1
- 11
- 24
python -c 'import tensorflow as tf; print(tf.__version__)' # for Python 2
python3 -c 'import tensorflow as tf; print(tf.__version__)' # for Python 3
Here -c represents program passed in as string (terminates option list)

- 3,126
- 28
- 25
If you have TensorFlow 2.x:
sess = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(log_device_placement=True))

- 31
- 2
-
1Why provide a partial answer to a 4 y/o question that already has multiple answers with very good acceptance? Does this provide any new knowledge? – Amitai Irron Jun 05 '20 at 15:27
-
@amitai, all packages and tools upgrade, and most of the time, errors are coming back. Old correct solutions may not work today. – Jade Cacho Jun 21 '20 at 14:58
For Windows cmd
pip list | FINDSTR tensorflow
OR
pip show tensorflow
For Linux
pip list | grep tensorflow
OR
pip show tensorflow

- 817
- 5
- 17
The version of Tensorflow can simply be checked on jupyter notebook using the following simple steps.
import tensorflow as tf
print(tf.__version__) # for Python 3

- 2,415
- 2
- 22
- 32

- 371
- 1
- 3
- 8
Printing python version in human readable format
python -c 'import sys; print(".".join(map(str, sys.version_info[:3])))'

- 25,609
- 37
- 148
- 229