
When trying to run Python commands in Windows, you might encounter this error message:
Python was not found;
run without arguments to install from the Microsoft Store,
or disable this shortcut from Settings > Manage App Execution Aliases.
This error might occur because of two possible scenarios:
- You have Python installed without adding Python.exe to PATH
- You don’t have Python installed
This tutorial will show you how to fix this error in each scenario.
1. You have Python installed without adding Python.exe to PATH
If you already have Python installed, then this error means Windows can’t find the path to that Python installation.
To verify you have Python installed, run the following command:
py --version
If you see a similar output as follows:
C:\Users\nsebhastian>py --version
Python 3.10.8
Then that means Python is indeed installed, but the python alias to run it is not added. By default, Windows uses the py alias to run the Python interpreter.
One way to enable the python command is to add the python.exe executable file to your PATH environment variable.
First, find the path to python.exe file using this command:
py -c "import sys; print(sys.executable)"
You should see a similar output as follows:
C:\Users\nsebhastian>py -c "import sys; print(sys.executable)"
C:\Users\nsebhastian\AppData\Local\Programs\Python\Python310\python.exe
Next, you need to add the full path to the folder where python.exe is located in your PATH variable.
From the command prompt, run the setx command as shown below:
setx path "%PATH%;<your path here>"
Replace <your path here> with the path you get previously:
setx path "%PATH%;C:\Users\nsebhastian\AppData\Local\Programs\Python\Python310"
Now close your command prompt and open it again. This time, you can run the python command:
Notice that the error is now fixed.
2. You don’t have Python installed
If you don’t have Python installed, then you need to install Python either from the Microsoft Store or the official Python website at https://python.org.
If you get the installer from python.org, make sure that you check the option ‘Add python.exe to PATH’ when running the installer:
Without checking the option, you can only run Python using the py command.
Continue the rest of the installation process, and you should be able to run the python command from the command prompt once the installation is finished.
Conclusion
To resolve the error “Python was not found; run without arguments to install from the Microsoft Store”, you need to make sure that you have Python installed on your machine and that python.exe was added to the PATH variable.
If you have Python installed but didn’t add the path to the executable file, then you can only run Python using the py alias.
I hope this tutorial is helpful. Happy coding! 👍

