Which version of Python do I have installed?

2019-01-20 21:39发布

I have to run a Python script on a Windows server. How can I know which version of Python I have, and does it even really matter? I was thinking of updating to latest version of Python.

18条回答
一纸荒年 Trace。
2楼-- · 2019-01-20 22:35

I have Python 3.7.0 on Windows 10. This is what worked for me in the command prompt and git bash:

To run Python and check version:

py

To only check which version you have:

py --version

or

py -V    #make sure it is a capital V

Note: python, python --version, python -V,Python, Python --version, Python -V did not work for me. Posted this answer in case others had the same issue.

查看更多
叛逆
3楼-- · 2019-01-20 22:40

Just create a file ending with .py and paste the code bellow into and run it.

#!/usr/bin/python3.6

import platform
import sys

def linux_dist():
  try:
    return platform.linux_distribution()
  except:
    return "N/A"

print("""Python version: %s
dist: %s
linux_distribution: %s
system: %s
machine: %s
platform: %s
uname: %s
version: %s
""" % (
sys.version.split('\n'),
str(platform.dist()),
linux_dist(),
platform.system(),
platform.machine(),
platform.platform(),
platform.uname(),
platform.version(),
))

If several Python interpreter versions are installed on a system, run the following commands.

On Linux run in terminal:

ll /usr/bin/python*

On Windows run in command prompt:

dir %LOCALAPPDATA%\Programs\Python
查看更多
SAY GOODBYE
4楼-- · 2019-01-20 22:41

For me. open CMD and run py it will show something like Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.

查看更多
别忘想泡老子
5楼-- · 2019-01-20 22:41

If you have Python installed then the easiest way you can check the version number is by typing "python" in your command prompt. It will show you the version number and if it is running on 32 bit or 64 bit and some other information. For some applications you would want to have a latest version and sometimes not. It depends on what packages you want to install or use.

查看更多
我只想做你的唯一
6楼-- · 2019-01-20 22:45
python -V

http://docs.python.org/using/cmdline.html#generic-options

--version may also work (introduced in version 2.5)

查看更多
叛逆
7楼-- · 2019-01-20 22:45

When I open Python (command line) the first thing it tells me is the version.

查看更多
登录 后发表回答