Add Python to PATH on Windows
Learn how to add the folder containing python.exe to the Windows PATH variable, then verify Python from Command Prompt.
If Python is installed on Windows but the python command does not work in Command Prompt, the interpreter directory may not be in the Windows PATH. This guide shows how to find python.exe, add its folder safely, and test the result.
What the Windows PATH variable does
PATH is an environment variable: a named operating-system setting inherited by applications and command shells. Its value is an ordered list of folders.
When you enter a command without a full file location, Command Prompt searches those folders for a matching executable. For example, when you enter python, Windows searches PATH directories for python.exe.
The command works only when the folder containing the interpreter is included in PATH, or when you provide the interpreter's full path directly.
Recognize the PATH problem
Open a new Command Prompt window and enter:
python
A typical failure looks like this:
'python' is not recognized as an internal or external command, operable program or batch file.
This means the shell did not locate a matching Python executable through PATH. It is a command lookup problem, not a Python syntax error or necessarily a failed installation.
On some Windows systems, entering python may instead open the Microsoft Store or suggest installing Python. This can happen when Windows App execution aliases intercept the command.
Confirm Python with its full path
A full path is the complete location of a file. If you know where Python is installed, run python.exe directly:
C:\Python34\python.exe --version
The actual location may be different. A successful result resembles:
Python 3.4.x
This test confirms that Python is installed and identifies the folder that should be added to PATH. The correct PATH entry is the folder containing python.exe, such as C:\Python34; do not add the executable filename itself.
Find the Python installation directory
Installation locations vary according to the Python version, installer choices, Windows account, and whether Python was installed for one user or for all users. Check the folder selected during installation, or search for python.exe in File Explorer.
The Python launcher may also be available. It is a Windows-specific command named py that can find and select installed Python versions:
py --version
py -0p
py -0p lists installations known to the launcher, including their paths, when that launcher version supports the option.
Common locations include a custom folder such as C:\Python34, a per-user installation under your Windows profile, or a system-wide installation under a program directory. Always verify that the chosen folder actually contains python.exe.
Add Python to PATH through Windows settings
- Press Windows key + R to open the Run dialog.
- Enter
sysdm.cpland press Enter. - Open the Advanced tab in System Properties.
- Select Environment Variables.
- In either the User variables or System variables section, select the variable named
Path. - Select Edit.
- Choose New in the current Windows PATH editor.
- Enter the directory containing
python.exe, for exampleC:\Python34. - Confirm with OK in each open dialog so the change is saved.
Current Windows editors display PATH entries as separate rows. Older interfaces may show one long value; in that case, separate directory entries with a semicolon (;). Do not delete or replace the existing PATH value. Add Python as another entry.
User PATH versus System PATH
| PATH scope | Who is affected | Administrator access | Appropriate use case |
|---|---|---|---|
| User Path | Only the current Windows account | Usually not required | Python is intended for one user |
| System Path | Windows users on the computer | Often required | Python should be available system-wide |
Choose User Path for a personal installation or when you do not have administrator access. Choose System Path when all users should be able to run the installation and you have permission to change system settings. A system-level change may require administrator approval.
Apply and test the PATH change
Existing Command Prompt and terminal windows keep the environment they received when they opened. Close the old windows and open a new Command Prompt.
Then run:
python --version
where python
python --version confirms which interpreter the python command starts. where python displays executable locations that Windows can resolve through PATH.
For example, a successful result might be:
Python 3.x.x
C:\Python34\python.exe
If several Python installations are in PATH, the first matching executable normally wins. This rule is called PATH precedence. The order of entries can therefore determine which Python version runs.
Common Python command outcomes
| Command | Expected result | What it indicates | Next action |
|---|---|---|---|
python | Interactive Python prompt starts | PATH found an interpreter | Use exit() to leave, or run a version check |
python --version | A Python version is printed | The python command resolves successfully | Continue using Python or inspect the selected file |
where python | One or more executable paths | Shows PATH-resolved Python files and their precedence | Review ordering if the wrong version runs |
py --version | A launcher version is printed | The Python launcher is installed | Use launcher options to select versions |
C:\Python34\python.exe --version | A Python version is printed | The installation works when addressed directly | Add its containing folder to PATH |
Python folders that may need PATH entries
| Folder purpose | Example location pattern | When to add it | Commands enabled |
|---|---|---|---|
| Python interpreter folder | C:\Python34 or the folder containing python.exe | Required for the python command | python and python --version |
| Scripts folder | Python installation folder followed by Scripts | Add when pip-installed command-line tools are not found | Utilities installed by pip |
| Per-user installation | A Python directory under the current user's profile | Use for an installation available to one account | That user's interpreter and tools |
| System-wide installation | A shared program directory or custom system folder | Use when Python is installed for all users | Interpreter and tools available according to permissions |
Installer-based PATH setup
The Python installer commonly provides an option such as Add Python to PATH. Selecting it during installation adds the relevant interpreter directory, and sometimes the Scripts directory, automatically.
If Python is already installed, rerunning the installer and choosing a modify or repair option may provide an alternative to manual editing. Manual PATH editing is useful when the existing installation uses a custom location or when you need to correct only one missing entry.
Optional: add the Scripts directory
The interpreter directory and the Scripts directory serve different purposes. The interpreter directory contains python.exe. The Scripts directory commonly contains executables installed by pip, such as command-line utilities.
If Python works but a pip-installed command does not, find the Scripts folder belonging to the active installation and add it as a separate PATH entry. Its exact location depends on the Python version, installation method, and user scope.
python -m pip --version
Using python -m pip helps ensure that pip belongs to the same interpreter as the python command. After adding Scripts, open a new terminal before testing the utility.
Python command alternatives and conflicts
The py launcher
python is resolved through PATH, while py uses the Windows Python launcher when installed. Consequently, the two commands can select different installations.
Use py -0p to inspect installations known to the launcher. A version-specific launcher command can select a particular installed version when supported, while changing PATH affects which executable the unqualified python command finds.
Microsoft Store app execution aliases
Windows App execution aliases are command aliases that can redirect names such as python. If python opens the Microsoft Store even though a full-path test works, add the correct interpreter directory to PATH and review the Python-related aliases in Windows app settings.
Multiple installations
Run where python to see PATH-resolved executables and py -0p to inspect launcher-known installations. Reorder PATH entries if the wrong installation is selected, or use an explicit launcher version selector when you need a particular version.
Troubleshooting
Python is still not recognized
- Close every Command Prompt window and open a new one.
- Confirm that
python.exeexists in the directory you added. - Make sure you added the containing folder, not
python.exeitself. - Check that the PATH edit was saved with OK in all dialogs.
- Verify that you changed the scope used by your account: User Path or System Path.
- Run Python by its full path and then run
where pythonin the new terminal.
A different Python version starts
- Run
where pythonand inspect the order of the results. - Run
py -0pif the launcher is available. - Move the desired interpreter directory earlier in PATH, or select a version explicitly with the launcher.
Python opens the Microsoft Store
- Run the installed interpreter using its full path to confirm that it exists.
- Add the folder containing that interpreter to PATH.
- Review Windows App execution aliases if
pythonremains redirected.
A pip-installed command is not recognized
- Identify the Scripts directory associated with the active Python installation.
- Add that directory as a separate PATH entry when global command access is needed.
- Use
python -m pipso packages are installed for the intended interpreter.
Existing commands stopped working
This usually means the existing PATH value was overwritten or malformed. Restore removed entries from a backup or known configuration, then add Python as a new entry rather than replacing the complete PATH. The modern multi-entry editor helps prevent this mistake.
Quick checklist
- Find and verify
python.exe. - Run its full path with
--version. - Add the containing directory to User Path or System Path.
- Do not replace existing PATH entries.
- Optionally add the related Scripts directory for pip-installed commands.
- Open a new Command Prompt.
- Run
python --versionandwhere python.
For related command-line basics, see Python command line, installing Python on Windows, and running Python code.