How to get the version of tensorflow and python installed on my system?

Knowing the version of Python and tensorflow currently installed on your PC is important as tensorflow may not run on the latest version of python, or you installed a 32-bit version of python but tensorflow can only run on 64-bit python. Other compatibility problems I encountered include latest tensorflow version cannot run on old CPU that’s lack of some instruction set support. To debug this kind of compatibility issues, you need to check the version of python and tensorflow installed on your system.

To check the Python version, you need to issue the “python -V” command. The output would be “Python 3.0.0”. Note that the argument is the capitalized “V”.

To check the tensorflow version, you need to enter into the python console, then import the tensorflow package using “import tensorflow”. The version must be hidden in some variable in this package. But which?

Note that to display the value of a variable, you need to call a function “print”. In the python console, what you enter are ordinary python statements. There is no “command” to use. So “print var” is wrong. You need to use “print(var)”. Now which variable contains the current version of tensorflow?

Import tensorflow

None of the above prints works. It says like “AttributeError: module ‘tensorflow’ has no attribute ‘version'”.

To find the version of tensorflow, you need to know which variable to check. You can print all variables accessible through the tensorflow package using “dir(tensorflow)”. It outputs all the variable names, in which you can see a variable named “__version__”. Yes, that is the variable you should check to get the version of current tensorflow package.

import tensorflow



If you like my content, please consider buying me a coffee. Buy me a coffeeBuy me a coffee Thank you for your support!

Leave a Reply