Python is one of the most popular programming languages of all time. It’s easy to set up and learn and is quite powerful to the extent that you can use it for anything from programming electronics to writing complicated scripts.
That said, just like everything else in programming, there are usually bugs and glitches from time to time that can randomly slow down your workflow. In this article, we’re talking about the “Python was not found; run without arguments to install” error.
What causes this error?
The error is mainly caused by your operating system (Windows in this case) not being able to detect the Python installation or if the Path variable for Python isn’t set up correctly.
How to fix this?
Here are four fixes you can try out.
The most obvious thing first, if you’re assuming your Windows machine comes with Python installed, chances are you’re wrong. Luckily installing Python isn’t too different from installing anything else.
Just head over to the Python website and download the installer based on your OS architecture (x86 or x64). Once downloaded, run the installer and make sure it sets up the PATH variables correctly.
Set up the environment variables
Even if Python is installed on your computer if you haven’t set up the environment variables correctly, you’re going to run into problems. Here’s how you can set the correct environment variables for Python.
Step 1: Press Windows Key + R to open the Run prompt. Type sysdm.cpl and hit enter.
Step 2: Head over to the Advanced tab and click Environment Variables.
Step 3: Select Path under User variables and click Edit.
Step 4: Enter the installation paths for Python in the Edit environment variable window. The default Python installation paths for version 3.7 and above are as follows.
Make sure to change the aforementioned file paths according to your Windows user name and your installed Python version. Now restart your computer, and the error should be resolved.
Check App Execution Aliases
Sometimes app installers for Python can cause conflicts and make Windows not detect the language properly. Here’s how you can fix this.
Step 1: Press the Windows key + I to open Windows settings and click on Apps.
Step 2: Click Apps & features.
Step 3: Click More settings followed by App execution alias.
Step 4: Find and disable any Python app installers you see.
Restart your PC, and you should be good to go.
Run a clean install
If nothing else works, your best bet is to uninstall Python from your PC and reinstall it again from scratch. This ensures that any wrong variables or modules that might be installed in the wrong places get removed, and everything else is done from the beginning in the correct order.
Also read: Error: Legacy-install-failure: 3 Fixes