0

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 ?

2
  • 1
    The minor version number is the second one. The -64 is indicating a 64-bit architecture. If you want to get this part, you can go with @Rakesh answer. Commented Jan 18, 2018 at 15:45
  • I don't want the architecture number.. I've edited my question to remove the ambiguity.. :) Commented Jan 18, 2018 at 15:56

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

I don't want the architecture number.. I've edited my question to remove the ambiguity.. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.