16

I has downloaded python in python.org, and I wanted to check my python version, so I wrote python --version in cmd, but it said just Python, without version. Is there any other way to find out python version?

4
  • 4
    python -c "import sys; print(sys.version)" will do the trick. Commented Jun 15, 2021 at 1:42
  • 3
    That is weird that it just says Python, when I run python --version I get the exact number, how did you install Python on your computer? Commented Jun 15, 2021 at 1:42
  • @MattDMo I usually go with print(sys.version_info) Commented Jun 15, 2021 at 2:20
  • Are you using bash? If so, what do you get if you type type python? Commented Jun 15, 2021 at 21:17

5 Answers 5

8

If you have installed python3 then the correct way for checking the version is

py -3 --version

You can try running this code in command prompt, anoconda prompt and microsoft power shell.

Sign up to request clarification or add additional context in comments.

Comments

7

A way to do it is to actually start the python interpreter. You can do that with python command. This will start the repl and you will be able to see in the first line something like:

Python 2.7.18 (default, Mar 8 2021, 13:02:45) 

Or

Python 3.8.5 (default, Jan 27 2021, 15:41:15) 

Please check in the comments other valid ways to do it.

I am really curious on what is the root cause of your issue tho.

Comments

3

use py --version command to display the installed Python's version from cmd

Comments

3

For Python3 versions enter:

  • python -V in the command line:

  • py -V : print the Python version number and exit (also --version)
    when given twice -VV, print more information about the build.

  • enter py -h to check other parameters

1 Comment

I found your explanation of Python commands very helpful, thank you for sharing!
0

If you typed the python command into the cmd and it did not show the currently installed version of py then you may double-check that python is added to your environment variables. (assuming that python is successfully installed on your machine).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.