The Python Oracle

How to find which version of TensorFlow is installed in my system?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Orient Looping

--

Chapters
00:00 How To Find Which Version Of Tensorflow Is Installed In My System?
00:16 Accepted Answer Score 543
01:20 Answer 2 Score 130
01:47 Answer 3 Score 34
01:54 Answer 4 Score 24
02:01 Thank you

--

Full question
https://stackoverflow.com/questions/3854...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #ubuntu #tensorflow #commandline #version

#avk47



ACCEPTED ANSWER

Score 543


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)



ANSWER 2

Score 130


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__




ANSWER 3

Score 34


import tensorflow as tf

print(tf.VERSION)



ANSWER 4

Score 24


For python 3.6.2:

import tensorflow as tf

print(tf.version.VERSION)