Vatsal Prakash
Vatsal Prakash

Reputation: 558

Check python version build number

I need to check python version using a python script. I know that sys.version_info and platform.python_version() are used for the purpose but the problem is that the value they return are :

(2, 6, 6, 'final', 0) and 2.6.6

But I also need the the build number for my use-case which can be generated by rpm -qa | grep python* , e.g :

python-2.7.5-48.el7.x86_64

(build Number here being 48..) Is there any way to do it using a python script ?

Upvotes: 0

Views: 662

Answers (1)

Rakesh
Rakesh

Reputation: 82755

You can use the architecture method in platform module

import platform
print platform.python_version()
print platform.architecture()
print "Version: {}, Architecture: {}".format(platform.python_version(), platform.architecture()[0])

Result:

2.7.13
('32bit', 'WindowsPE')
Version: 2.7.13, Architecture: 32bit

Upvotes: 1

Related Questions