Search code examples
pythonwindowscmdinterpreter

Python version is being overridden


I try to install Python 3.10/3.11 on my Windows 10 machine. It works without any issues, but when I try to execute code from the terminal, it uses version 3.6.6. (Even though version 3.6.6 is not listed in my Python versions.)

C:\Windows\system32>python --version
Python 3.6.6

C:\Windows\system32>py --list
 -V:3.11 *        Python 3.11 (64-bit)
 -V:3.10          Python 3.10 (64-bit)
 -V:3.9           Python 3.9 (64-bit)
 -V:3.8           Python 3.8 (64-bit)

I tried editing my environment variables, and it looks just fine for version 3.11 (user Path):

C:\Users\chenb\AppData\Local\Programs\Python\Python311\Scripts\
C:\Users\chenb\AppData\Local\Programs\Python\Python311\
C:\Program Files\MySQL\MySQL Shell 8.0\bin\
C:\Users\chenb\AppData\Local\Microsoft\WindowsApps
C:\Users\chenb\AppData\Local\Programs\Microsoft VS Code\bin
C:\Program Files\Blace
D:\Blace
C:\Program Files\JetBeans\PyCharm 2021.3.3\bin
C:\Program Files\JetBeans\PyCharm Community Edition 2022.1\bin
D:\FFmpeg\bin
C:\Users\chenb\Desktop\FFmpeg\bin
C:\Program Files\PsynchoPy
C:\Users\chenb\Desktop\Coding\swigwin-4.1.1
C:\Users\chenb\anaconda3\Scripts
%IntelliJ IDEA Community Edition%
A:\src\flutter\bin
A:\PsychoPy
A:\PsychoPy\DLLs
C:\Users\chenb\AppData\Roaming\npm

When searching for Python 3.6 on my computer, there's a software called 'PsychoPy' that uses Python 3.6 (which I need):

Directory C:\Program Files\PsychoPy3 as shown in Windows File Explorer:

Name            Date modified       Type                      Size
------------------------------------------------------------------
DLLs            06/04/2023 20:58    File folder
include         06/04/2023 21:00    File folder
Lib             06/04/2023 21:00    File folder
libs            06/04/2023 21:00    File folder
man             06/04/2023 21:00    File folder
MinGit          06/04/2023 21:00    File folder
Scripts         06/04/2023 21:00    File folder
share           06/04/2023 21:00    File folder
tcl             06/04/2023 21:00    File folder
Tools           06/04/2023 21:00    File folder
CHANGEOG.txt    20/11/2020 20:15    Text Source File          158 KB
LICENSE.txt     17/05/2018 16:35    Text Source File            1 KB
LICENSES.txt    18/12/2014 17:53    Text Source File            4 KB
NEWS.txt        27/06/2018 5:43     Text Source File          395 KB
PsychoPy3       06/04/2023 21:01    Internet Shortcut           1 KB
python.exe      27/06/2018 5:40     Application                99 KB
python3.dll     27/06/2018 5:37     Application exten...       58 KB
python36.dll    27/06/2018 5:37     Application exten...    3,527 KB
python64.exe    27/06/2018 5:40     Application                99 KB
pythonw.exe     27/06/2018 5:40     Application                97 KB
uinst.exe       06/04/2023 21:01    Application                62 KB

Is it possible that the software is overriding my Python version?
Any idea how can I solve this issue?


Solution

  • Run set PATH in your terminal to check the current PATH variable in CMD. You should see that the path to the Python 3.6 executable is near the front.

    You are showing your user PATH variable, but there is also a system PATH variable that takes precedence in the PATH order. You can find the system PATH variable in the bottom pane of the Environmental Variables window.

    If it is not there, it could also be an AutoRun process that fires everytime you start CMD. That is controlled by a expandable string value AutoRun at the registry key

    HKCU\SOFTWARE\Microsoft\Command Processor
    

    If it is present, then the data attached to the AutoRun value is executed everytime CMD starts. This could be used to place the Python 3.6 as the alias to python