Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

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?

like image 326
MartyMacGyver Avatar asked Feb 17 '23 04:02

MartyMacGyver


1 Answers

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)" 
like image 143
poolie Avatar answered Apr 30 '23 20:04

poolie