independent full stack developer

/ Developer's blog

How to Solve the "Python was not found; run without arguments to install from the Microsoft Store" Error in Windows

Saturday, April 27, 2024

Python is a versatile and widely-used programming language that is popular for its readability, simplicity, and vast ecosystem of libraries and frameworks. However, Windows users might sometimes face an error that prevents them from running Python scripts or accessing the Python interpreter from the command line. The error message usually reads: "Python was not found; run without arguments to install from the Microsoft Store." This can be frustrating for developers who require Python for their projects.

The good news is that there's a relatively simple solution to this issue, which involves managing app execution aliases in the Windows settings. If you're encountering this error, follow the step-by-step instructions below to resolve it and get Python up and running on your system.

Step 1: Access the Start Menu
- Click on the Start button located at the bottom left corner of your screen, or press the Windows key on your keyboard.

Step 2: Search for Execution Aliases
- In the search field, type "Manage App Execution Aliases" and hit enter. Wait for the search results to display the relevant system settings.

Step 3: Open the App Execution Aliases Settings
- Click on the "Manage App Execution Aliases" option that appears in the search results. This will open a window where you can manage settings for app execution aliases.

Step 4: Locate the Python Aliases
- In the App Execution Aliases settings, scroll through the list until you find the entries related to Python. Typically, there will be two Python entries: "Python (command line)" and "Python3 (command line)."

Step 5: Turn Off the Python Aliases
- To the right of each Python entry, you'll notice a toggle switch. Turn these switches off by clicking on them. This action will disable the aliases that redirect the Python command to the Microsoft Store, allowing you to use your locally installed version of Python instead.

Step 6: Test Python in Command Prompt
- To confirm that the issue has been resolved, open the Command Prompt by typing "cmd" in the Start Menu search bar and selecting Command Prompt from the search results.
- Once the Command Prompt window is open, type "python" or "python3" and press Enter. You should now see the Python interpreter load successfully, displaying the version number and a prompt where you can type Python code.

Step 7: Set Up Environment Variables (Optional)
- If you're still encountering issues when trying to run Python from the command line, you may need to add Python to your system's PATH environment variable.
- Search for "Environment Variables" in the Start Menu, and select "Edit the system environment variables."
- In the System Properties window, click on the "Environment Variables" button.
- In the Environment Variables window, look for the "Path" variable in the "System variables" section and select it.
- Click "Edit" and add the path to the directory where Python is installed (usually something like C:\Python39) and the path to the Scripts folder (usually C:\Python39\Scripts).
- Click "OK" to save your changes, and test Python again in the Command Prompt.

Conclusion
Encountering the "Python was not found" error can be a bump in the road for Windows users, but following the above steps should smoothly guide you past this obstacle. By managing app execution aliases and optionally setting up environment variables, you can ensure that your system recognizes your Python installation. Now you can continue writing and executing Python code seamlessly on your Windows machine!

256 people already saw it