0

These are my environment variables:

PATH=C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\GitExtensions;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\GitExtensions;C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Users\oprisvlad2\AppData\Local\Microsoft\WindowsApps;C:\Users\oprisvlad2\AppData\Local\Programs\Git\cmd;C:\Program Files\Java\jdk-17\bin;C:\Python27\Scripts;C:\Python27;C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python 2.7;

The C:\Python27 and C:\Python27\Scripts are added but "py" is still unrecognized. I restarted my machine several times. I have look all over for solutions but none of them worked for me. I prefer something that works from the command prompt.

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
Opr Vld
  • 69
  • 1
  • 10
  • Does this answer your question? [How to fix error "'py.exe' is not recognized as an internal or external command, operable program or batch file"?](https://stackoverflow.com/questions/57384312/how-to-fix-error-py-exe-is-not-recognized-as-an-internal-or-external-command) – Karl Knechtel Sep 22 '22 at 00:51

1 Answers1

0

The py.exe executable is not found in the paths specified to windows environment. py.exe is a launcher for detecting specific python installations.

Try python to launch the default python.

Make sure that the paths to the python executable file are placed before the the windows app dir, otherwise it could lead to windows triggering to-be-installed python.

C:\Python27\Scripts;C:\Python27;C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python 2.7;C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Users\oprisvlad2\AppData\Local\Microsoft\WindowsApps

If you have py.exe somewhere, add the absolute path to evironment variable. Usually for newer python versions, if you install python via windows installer, the py is automatically added to the env variables.

Donut
  • 44
  • 4
  • Well, 'python' will prompt me to the microsoft store to install it. I have already installed it. – Opr Vld Oct 04 '21 at 08:30
  • Could you check which python executable (pythonxx.exe) is listed in C:\Python27? And are you sure you want to work with python2.7? - If not, try searching for python 3.9 in windows app store or directly download the windows installer to go for the a recent stable release. – Donut Oct 04 '21 at 08:36
  • In that directory I have python.exe and pythonw.exe. Yes, python 2.7 is required for my project. – Opr Vld Oct 04 '21 at 08:40
  • What terminal do you use? windows cmd oder some other terminal? If windows could you type - echo %PATH% and if other unix based ones echo $PATH to check it the path is read in correctly. Also try putting 'C:\Python27' as the first parameter. – Donut Oct 04 '21 at 08:44
  • yes, windows cmd – Opr Vld Oct 04 '21 at 08:45
  • Can you run it by specifying the abs path to the exe `C:\Python27\python.exe` ? – Donut Oct 04 '21 at 08:51
  • Yes, it can be run with that abs path. – Opr Vld Oct 04 '21 at 08:53
  • Then please put `C:\Python27` and `C:\Python27\Scripts` somewhere in near the starting section of the environment var paths. What does `where python` output? – Donut Oct 04 '21 at 08:58
  • C:\Python27\python.exe C:\Users\oprisvlad2\AppData\Local\Microsoft\WindowsApps\python.exe – Opr Vld Oct 04 '21 at 09:08
  • Remove `C:\Users\oprisvlad2\AppData\Local\Microsoft\WindowsApps` or move `C:\Python27` and other python27 paths so that it comes before `C:\Users\oprisvlad2\AppData\Local\Microsoft\WindowsApps` – Donut Oct 04 '21 at 09:13
  • @OprVld Just to test you can append to the PATH from cmd using `set PATH=C:\Python27\Scripts;C:\Python27;%PATH%` . – Donut Oct 04 '21 at 09:21
  • My path now looks like this but py is still not recognized: PATH=C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\GitExtensions\;C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Python27\Scripts\;C:\Python27\;C:\Users\oprisvlad2\AppData\Local\Microsoft\WindowsApps;C:\Users\oprisvlad2\AppData\Local\Programs\Git\cmd;C:\Program Files\Java\jdk-17\bin;C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python 2.7 – Opr Vld Oct 04 '21 at 09:21
  • 1
    Did you alread try `python` instead of `py` after your changes? – Donut Oct 04 '21 at 09:22