slumtrimpet slumtrimpet - 1 year ago 120
Python Question

Python Version (sys.version) Meaning?

I've hit what should be a basic question... but my googles are failing me and I need a sanity check.

If I run the following in my Python shell:

>>> import sys
>>> sys.version

from two different Python environments, I get:

'2.7.8 (default, Nov 10 2014, 08:19:18) \n[GCC 4.9.2 20141101 (Red Hat 4.9.2-1)]'


'2.7.8 (default, Apr 15 2015, 09:26:43) \n[GCC 4.9.2 20150212 (Red Hat 4.9.2-6)]'

Does that mean the two environments are actually running slightly different Python guts or is it enough that the '2.7.8' bit in that version string is the same so I can be confident these are 1:1 identical Python interpreters?

If I am guaranteed they are the same, then what's the significance of the date and other parts of that version output string?

Answer Source

All you need to compare is the first bit, the 2.7.8 string.

The differences you see are due to the compiler used to build the binary, and when the binary was built. That shouldn't really make a difference here.

The string is comprised of information you can find in machine-readable form elsewhere; specifically:

For your sample strings, what differs is the date the binary was build (second value of the platform.python_build() tuple) and the exact revision of the GCC compiler used (from the platform.python_compiler() string). Only when there are specific problems with the compiler would this matter.

You should normally only care about the Python version information, which is more readily available as the sys.version_info tuple.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download