I bought my new Asus laptop and after trying to run Python I encountered the "Python was not found; run without arguments to install from the Microsoft Store or disable this shortcut from Settings > manage app execution aliases" error. If you too have recently faced this issue, I have found a simple solution. Follow along to get Python up and running on your system in no time.
Understanding the Error
At CodeWithHarry, my aim is to help you understand how things work and why you got this error in the first place.
This error typically occurs when the Python interpreter's path is not correctly set in your environment variables. This can happen for a variety of reasons, including improper installation or system updates. The good news? The fix is straightforward.
For most people, the simple fix is to install Python from the official Python website and check the "Add Python to environment variables" option during installation.
If you already have Python installed, follow the steps below:
Step 1: Locate Your Python Installation Paths
First, you need to find the paths where your Python interpreter is installed. The paths are usually one of the below:
%AppData%\Programs\Python\Python311
%AppData%\Programs\Python\Python311\Scripts
But if you are having trouble finding your Python installation, here is a quick guide I wrote for exactly that.
Step 2: Access and Set the Path Environment Variables
Search for "Environment Variables" in Windows search as shown below:
Navigate to the System Properties, and then click on the "Environment Variables" button.
Step 3: Modify the System Variables
Click on the "System variables" and then click "Path" as shown below:
After you select the "Path" variable, click "Edit."
Click "New" and then add the previously copied Python paths to the list.
This is what it will look like:
Note: The key to solving this issue lies in adding the Python paths to the System variables, not the User variables. I initially made the mistake of using the User variables, which led to another error. Hence, I want to make sure you do not repeat the mistake I did!
Conclusion
And that's it! You've successfully fixed the "Python was not found" error on your computer. By following these simple steps, you should now be able to use Python. If you have any questions or need further assistance, feel free to leave a comment below. Happy coding!