not able to uninstall python and get python 3

Viewed 39

i just started using python and i use VS Code.

When i do

python --verion

i get python version 2

py --version

i get python version 3

i wanted to install networkx which turned out to only work with python version 3. I did multiple things to change python version to 3 but could not.

So i decided to uninstall python and went to control panel and uninstalled

python
python launcher

and restarted the computer.

But when i run

python --version

it still shows up python 2.7.18

and this is my where python output

enter image description here

can anyone please help me to understand whats going on and how can i get python 3 to my system.

enter image description here

My solution:

I had already tried putting the python 3.1 path (default added by python when you click add path option while installing) above all path but had no intended outcome.

What i did:

installed python again and this time added the path by myself and moved it to top.

Now when i run

where.exe python it shows me three path, i don't know much but looks like there are two/three python in the system but it started showing python 3 for now.

my where.exe python output:

enter image description here

uninstalled

1 Answers

In windows If you do not have correct environment variable set then this is likely to cause the problem.

On your Powershell if you type $env:path or on command prompt echo %PATH%

you shall see your environment variable path which you have set,

where-in, either you may not have path to directory of Python 3 or you have it appended after Python2.

i.e.:

if your result show up as (... could be other paths in your variable) then only you will get python.exe to be pointing to your Python3 path:

...
C:\Python38\Scripts;C:\Python38;
...
C:\Python27\Scripts;C:\Python27\;
...

Update:

Based on OP comment it looks like there is misunderstanding with how environment variable works.

If you are still looking for why question then follow below steps:

  1. List down all paths which are under environment variable PATH

  2. Now go over each path and check contents of the directory. One of the directory would be having the python which is throwing you the version which you find mystery.

Related