0

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?

Mofi
  • 46,139
  • 17
  • 80
  • 143
ChenBr
  • 1,671
  • 1
  • 7
  • 21

2 Answers2

2

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

James
  • 32,991
  • 4
  • 47
  • 70
  • You are right; it was inside the system PATH. I modified it, and it now works. I fixed it by deleting Python 3.6, which is a temporary solution. I will probably move to version management, as Pronex suggested. Thank you for the help! – ChenBr Jun 28 '23 at 13:04
  • The hint is good checking __system__ `PATH` and adapt the folder path. The advice to use the `AutoRun` registry string value to define the __local__ `PATH` on starting `cmd.exe` is very bad. The command line defined with the `AutoRun` registry value is executed always by `cmd.exe` on not using option `/D` independent on which process started it, the user from Windows Desktop (`explorer.exe`) or any other process. There are thousands of applications running `cmd.exe` in background. An `AutoRun` registry value which redefines __local__ `PATH` could cause lots of troubles. Do not add `AutoRun`. – Mofi Jun 28 '23 at 17:16
1

You're probably right, as the system will find python.exe in multiple places. If you don't have the option to clean this up, you could try changing the order of the environment variables list so that the most important one is at the beginning. In Linux system the order matters, and I'm guessing this is also the case on Windows.

In either case, you can find out which one you're getting by using the where python command (similar to the which command in Linux).

Pronex
  • 274
  • 3
  • 14
  • Hello, thank you for the help. Unfortunately, changing the order in the environment variables doesn't change Python's version. As I suspected and as you suggested as well, the `where python` command produces the following: https://i.gyazo.com/0258ef52af61f1d6f2a5f2dd36c38aa0.png (multiple versions all over the place) – ChenBr Jun 28 '23 at 12:36
  • 1
    Oh wow. Well you could really think about removing the other versions and using a version management for python or virtual environments. – Pronex Jun 28 '23 at 12:40
  • Thanks for the suggestion; I will have a look at version management! – ChenBr Jun 28 '23 at 13:11
  • The order of the folder paths in __local__ environment variable `PATH` matters also on Windows. Please take a look on [What is the reason for "X is not recognized as an internal or external command, operable program or batch file"?](https://stackoverflow.com/a/41461002/3074564) There was most likely not closed the already opened command prompt window and opened a new one after editing __system__ `PATH` via the graphical user interface of Windows. That is necessary on every modification of any __system__ or __user__ environment variable. Best is a restart of Windows on __system__ `PATH` change. – Mofi Jun 28 '23 at 17:20