Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
version/compile info
#1
when i start up python or python3 with no arguments to get the interactive mode, at first it outputs 2 lines of information and a line of instructions. the 2nd line appears to be compilation information. how can i get all of this information in a python script? i hope the method is the same in both python2 and python3.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
>>> sys.version
'3.6.4 (default, Jan  5 2018, 02:35:40) \n[GCC 7.2.1 20171224]'
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
what did you get as a banner when you started python? is it the same?

Output:
lt1/forums /home/forums 1> python3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.version=='[GCC 5.4.0 20160609] on linux' False >>> lt1/forums /home/forums 2> python2 Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.version=='[GCC 5.4.0 20160609] on linux2' False >>> lt1/forums /home/forums 3>
apparently these two versions of Python were compiled on different hosts. i'm assuming that's what "linux" and "linux2" mean (maybe not). if anyone has Python on a different architecture, maybe they can show what they have.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
(May-14-2018, 05:11 AM)Skaperen Wrote: what did you get as a banner when you started python? is it the same?

Python 3.6.4 (default, Jan 5 2018, 02:35:40)
[GCC 7.2.1 20171224] on linux
Type "help", "copyright", "credits" or "license" for more information.


I would say yes. Without the last line.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#5
print('Python ' + sys.version)
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#6
According to the 2nd reference below in Python 3 documentation:
Quote:sys.version
A string containing the version number of the Python interpreter plus additional information on the build number and compiler used. This string is displayed when the interactive interpreter is started. Do not extract version information out of it, rather, use version_info and the functions provided by the platform module.


platform.python_version() Reference: https://docs.python.org/3/library/platfo...on_version
sys.version Reference: https://docs.python.org/3/library/sys.ht...ys.version
sys.version_info Reference: https://docs.python.org/3/library/sys.ht...rsion_info

The following code works in both Python 2 and Python 3:
import platform
import sys

print("platform.python_version(): {}".format(platform.python_version()))

print("sys.version:               {}".format(sys.version))
print("sys.version_info:          {}".format(sys.version_info))
print("sys.version_info.major:    {}".format(sys.version_info.major))
Output:
platform.python_version(): 2.7.13 sys.version: 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] sys.version_info: sys.version_info(major=2, minor=7, micro=13, releaselevel='final', serial=0) sys.version_info.major: 2
Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00
Reply
#7
Quote:Skaperen Wrote:
what did you get as a banner when you started python? is it the same?

Windows 10 - 32 bit Python:
Output:
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00
Reply
#8
(May-14-2018, 02:39 PM)ljmetzger Wrote:
Quote:Skaperen Wrote:
what did you get as a banner when you started python? is it the same?

Windows 10 - 32 bit Python:
Output:
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
Lewis
does sys.version include "win32" for you?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#9
Quote:Skaperen Wrote:
does sys.version include "win32" for you?

64 bit Windows 10 - 32 bit Python
'win32' is returned by sys.platform

import platform
import sys
 
print("platform.python_version(): {}".format(platform.python_version()))
print("platform.platform(): {}".format(platform.platform()))
print("platform.uname(): {}".format(platform.uname()))

print("platform.system(): {}".format(platform.system()))
print("platform.release(): {}".format(platform.release()))
print("platform.version(): {}".format(platform.version()))

system = platform.system()
release = platform.release()
version = platform.version()
print("platform.system_alias(system, release, version): {}".format(platform.system_alias(system, release, version)))
 
print("")
print("sys.platform:              {}".format(sys.platform))
print("sys.version:               {}".format(sys.version))
print("sys.version_info:          {}".format(sys.version_info))
print("sys.version_info.major:    {}".format(sys.version_info.major))
Output:
platform.python_version(): 3.6.5 platform.platform(): Windows-10-10.0.16299-SP0 platform.uname(): uname_result(system='Windows', node='DESKTOP-JGK8FPV', release='10', version='10.0.16299', machine='AMD64', processor='Intel64 Family 6 Model 94 Stepping 3, GenuineIntel')ssor='Intel64 Family 6 Model 94 Stepping 3, GenuineIntel') platform.system(): Windows platform.release(): 10 platform.version(): 10.0.16299 platform.system_alias(system, release, version): ('Windows', '10', '10.0.16299') sys.platform: win32 sys.version: 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] sys.version_info: sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0) sys.version_info.major: 3
Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00
Reply
#10
so that's where it comes from. what does the "2" mean if python3 does not have it?
Output:
lt1/forums /home/forums 1> py2 Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.platform 'linux2' >>> lt1/forums /home/forums 2> py3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.platform 'linux' >>> lt1/forums /home/forums 3>
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  What is all the info in the info window in Idle? Pedroski55 3 693 Jul-08-2023, 11:26 AM
Last Post: DeaD_EyE
  Can I upload a new version without previously deleting ancient version sylas 6 4,273 Nov-08-2017, 03:26 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020