I am aware that this question keeps popping up, but I have tried most of the methods mentioned in the replies that I have seen for other questions and I am still facing this problem. I need my scripts to run with python 3.8.5 that I have installed at the location "C:\Python\Python3.8.5".
When I run py --version
in the terminal, the output I get is Python 3.8.5
. This is exactly as expected.
But when I make a script called print_sys.py as such,
import sys
print(sys.version)
and then run this by typing .\print_sys.py
,
I get the output as 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)]
On the other hand, if I run this same script by typing py print_sys.py
, I get the output as 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)]
I want it to run the script with python3.8.5 when I try to execute the script by typing .\print_sys.py
In case it helps this is what my path variable in system variables look like.
This is what my PYTHONPATH variable in system variables looks like.
And this is what my path variable in user variables looks like
I suspect that it's that last python 2.7 from the windows build tools that is the problem but I don't see how that could be since python 3.8.5 comes first.
EDIT: I finally found a solution that works for me. I referred to this youtube video to find out how to change the file association for .py files on my machine. I still don't understand why just changing the order of the path variables didn't work so if anyone has any idea about that your answers will still be appreciated.