Which version of Python do I have installed?

The Question :

480 people think this question is useful

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 the latest version of Python.

The Question Comments :

The Answer 1

640 people think this answer is useful
python -V


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

The Answer 2

136 people think this answer is useful

Python 2.5+:

python --version

Python 2.4-:

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

The Answer 3

132 people think this answer is useful

In a Python IDE, just copy and paste in the following code and run it (the version will come up in the output area):

import sys

The Answer 4

30 people think this answer is useful

At a command prompt type:

python -V

Or if you have pyenv:

pyenv versions

The Answer 5

24 people think this answer is useful

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

The Answer 6

24 people think this answer is useful

Although the question is “which version am I using?”, this may not actually be everything you need to know. You may have other versions installed and this can cause problems, particularly when installing additional modules. This is my rough-and-ready approach to finding out what versions are installed:

updatedb                  # Be in root for this
locate site.py            # All installations I've ever seen have this

The output for a single Python installation should look something like this:


Multiple installations will have output something like this:


The Answer 7

11 people think this answer is useful
In [1]: import sys

In [2]: sys.version
2.7.11 |Anaconda 2.5.0 (64-bit)| (default, Dec  6 2015, 18:08:32) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]

In [3]: sys.version_info
sys.version_info(major=2, minor=7, micro=11, releaselevel='final', serial=0)

In [4]: sys.version_info >= (2,7)
Out[4]: True

In [5]: sys.version_info >= (3,)
Out[5]: False

The Answer 8

11 people think this answer is useful

In short:

Type python in a command prompt

Simply open the command prompt (Win + R) and type cmd and in the command prompt then typing python will give you all necessary information regarding versions:

Python version

The Answer 9

7 people think this answer is useful
>>> import sys; print('{0[0]}.{0[1]}'.format(sys.version_info))

so from the command line:

python -c "import sys; print('{0[0]}.{0[1]}'.format(sys.version_info))"

The Answer 10

7 people think this answer is useful


python -V


python --version

NOTE: Please note that the “V” in the python -V command is capital V. python -v (small “v”) will launch Python in verbose mode.

The Answer 11

7 people think this answer is useful

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 the version:


To only check which version you have:

py --version


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.

The Answer 12

5 people think this answer is useful

You can get the version of Python by using the following command

python --version

You can even get the version of any package installed in venv using pip freeze as:

pip freeze | grep "package name"

Or using the Python interpreter as:

In [1]: import django
In [2]: django.VERSION
Out[2]: (1, 6, 1, 'final', 0)

The Answer 13

5 people think this answer is useful

To check the Python version in a Jupyter notebook, you can use:

from platform import python_version

to get version number, as:



import sys

to get more information, as

3.7.3 (default, Apr 24 2019, 13:20:13) [MSC v.1915 32 bit (Intel)]



to get major, minor and micro versions, as

sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)

The Answer 14

4 people think this answer is useful

If you are already in a REPL window and don’t see the welcome message with the version number, you can use help() to see the major and minor version:

Welcome to Python 3.6's help utility!

The Answer 15

4 people think this answer is useful

Typing where python on Windows into a Command Prompt may tell you where multiple different versions of python are installed, assuming they have been added to your path.

Typing python -V into the Command Prompt should display the version.

The Answer 16

3 people think this answer is useful

To verify the Python version for commands on Windows, run the following commands in a command prompt and verify the output:

c:\> python -V
Python 2.7.16

c:\> py -2 -V
Python 2.7.16

c:\> py -3 -V
Python 3.7.3

Also, to see the folder configuration for each Python version, run the following commands:

For Python 2, 'py -2 -m site'
For Python 3, 'py -3 -m site'

The Answer 17

3 people think this answer is useful

On Windows 10 with Python 3.9.1, using the command line:

    py -V

Python 3.9.1

    py --version

Python 3.9.1

The Answer 18

2 people think this answer is useful

For me, opening CMD and running


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.

The Answer 19

2 people think this answer is useful

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


import platform
import sys

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

print("""Python version: %s
dist: %s
linux_distribution: %s
system: %s
machine: %s
platform: %s
uname: %s
version: %s
""" % (

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

On Linux, run in a terminal:

ll /usr/bin/python*

On Windows, run in a command prompt:

dir %LOCALAPPDATA%\Programs\Python

The Answer 20

1 people think this answer is useful

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.

The Answer 21

0 people think this answer is useful

For bash scripts this would be the easiest way:

# In the form major.minor.micro e.g. '3.6.8'
# The second part excludes the 'Python ' prefix 
PYTHON_VERSION=`python3 --version | awk '{print $2}'`
echo "python3 version: ${PYTHON_VERSION}"
python3 version: 3.6.8

And if you just need the major.minor version (e.g. 3.6) you can either use the above and then pick the first 3 characters:

PYTHON_VERSION=`python3 --version | awk '{print $2}'`
echo "python3 major.minor: ${PYTHON_VERSION:0:3}"
python3 major.minor: 3.6


PYTHON_VERSION=`python3 -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))'`
echo "python3 major.minor: ${PYTHON_VERSION}"
python3 major.minor: 3.6

The Answer 22

-1 people think this answer is useful

Open a command prompt window (press Windows + R, type in cmd, and hit Enter).

Type python.exe

The Answer 23

-1 people think this answer is useful

Mostly usage commands:

python -version


python -V

Add a Comment