MartyMacGyver
MartyMacGyver

Reputation: 10093

How would I get the detailed version of my Python interpreter via a one-liner or command-line option?

The output of --version itself is a little too brief:

C:\>python --version
Python 2.7.5

However, if I run Python from the command prompt, I get something similar to the following, with verbose version info for the interpreter all on one line:

C:\> python
Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Is there a simple way, in a one-line command or via some options to get that same verbose version info line as a string that I could use to populate an environment variable or such?

In effect, is there a more verbose variant of --version I'm unaware of?

Upvotes: 5

Views: 1612

Answers (1)

poolie
poolie

Reputation: 9515

python -c "import sys;print(sys.version)"

is the basics; or to get closer to the same thing:

python -c "import sys;print('Python '+sys.version.replace('\n','')+' on '+sys.platform)" 

Upvotes: 8

Related Questions