Table of Contents Hide
If you have not installed Python on your windows machine or if the path environment variables are not set properly in windows you will get Python was not found error.
In this tutorial, we will learn how to resolve Python was not found; run without arguments to install from the Microsoft Store error
How to solve Python was not found; run without arguments to install from the Microsoft Store
The error mainly occurs in the windows operating system and there are different reasons to get this issue. Let us take a look at each of these scenarios and solutions.
Scenario 1: Python is not installed
The main reason could be that Python software itself is not installed on the windows machine and, you are trying to execute Python scripts or installing the packages.
This is a rare scenario where some beginners think that by default the Python software is shipped with windows and try to run the Python scripts.
The solution is pretty straightforward and, we can download the latest version of Python from the official source and install it in windows to resolve the issue.
Scenario 2: Environment variables are not set properly
The second scenario could be you have installed the Python software, but when you run the scripts or the project through the command line, you get Python was not found error.
It happens because the environment path variable does not exist for Python.
You can resolve the issue by setting the environment path variable for Python as shown below.
Step 1: Find the installed path of the Python software if you have installed it in a different location. The default installation path for Python 3.7+ versions is located as shown below.
Step 2: Copy the two Python paths. Replace the <user_name> with your actual user name.
Step 3: These are the Path for the Python interpreter. We need to add this into the system environment variable Path as shown in the below screenshot.
Right-click This PC, then go to Properties => Advanced system settings => Environment variables.
Step 4: You’ll see your variables here. Select the PATH variable and click the “Edit” button. In the window that appears when a path variable exists, select it and click Edit; otherwise, click New.
Step 5: Finally, paste the path you copied earlier in Step 1. If your system has many paths linked by semicolons, append the path by prefacing it with a semicolon. Click Ok to save.
Once you have completed all the steps, try running the Python program from your command prompt. You can run the ‘py’ or ‘python’ command, and you should not see any error hereafter. Remember to close all the command prompt windows and reopen them again after completing the above steps.
Step 5: Restart the machine once and try running the scripts.
Scenario 3: Manage App Execution Aliases
In Windows start, search for Manage App Execution Aliases and turn of the app installers for Python as shown in the below screenshot.
Scenario 4: Clean Install
If you have tried all the above methods and still it did not work, then you can uninstall the existing Python installation and perform a clean installation of Python.
During the installation, ensure to Add the Path environment variables to set the paths properly.
Once you re-install the Python, ensure to reboot the windows machine before executing the Python scripts.