Python versions in my PC shows 2.7.17 instead of 3.8.5

Viewed 3943

cmd python version

Yesterday I've been trying to install Python 3.8.5. I got the installer from the python website. My problem is that whenever I run python --version in the command line, it keeps saying, like in the image above, Python 2.7.17.

Today I also installed the Microsoft store package, and it's the same.

But running py apparently gives me the correct version 3.8.5. Does this mean that every python program I'll write will use the current version? That's what I currently want to make sure of.

As a side note also, I uninstalled all other python versions except 3.8.5 that I saw in my settings>Apps list. So, that adds to my confusion why running python --version would still show 2.7.17.

Maybe not as relevant, but I also have WSL2 enabled on my machine, I would like to install python to both. At the moment I'm focusing on the Windows10 part, but if there's a solution that will help both, that'll be awesome.

Thanks in advance!

[update]: adding python3 --version screenshot python3 --version

[update]: yet another confusing part for me:

py -V vs python -V

  • should I just let this be?
  • Is this something I need to straighten up first before moving forward?
  • are my python programs going to be ran in version 3.8.5 and not 2.7.17?
3 Answers

I know my answer is very late but i see a lot of people facing this problem. So if you want to interact with the latest Python version in your command prompt, you just need to set newer (or which one you want) Python path variable above/before other Python version's path variables. This solution also helped me a lot with other path problems.

This is a problem with your PATH environment variable being set incorrectly. I'm guessing that you installed Python 3 globally, after you had Python 2.7 installed. Whenever you do this and have the option Add to PATH checked, it will overwrite the default python location to the new install, thus causing Python 3 to now open instead. You can change this back manually by changing the value in PATH.

I'd suggest using something like pipenv to manage your python versions and respective libraries, that will create a sandbox for your application to run in and will always point to the correct dependencies.

py -V and python -V now showing same result

Ok, so hopefully this fixes every question I had. Hopefully comments will assure me that is so.

What I did was, delete the environment variables relating to Python 27. Found the Python3.exe path and added that to the path variable. Not exactly sure how that works, but it did give me the outcome I wanted to see.

Related