Python online course

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

  1. Press Windows key + R to open the Run dialog.
  2. Enter sysdm.cpl and press Enter.
  3. Open the Advanced tab in System Properties.
  4. Select Environment Variables.
  5. In either the User variables or System variables section, select the variable named Path.
  6. Select Edit.
  7. Choose New in the current Windows PATH editor.
  8. Enter the directory containing python.exe, for example C:\Python34.
  9. 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 scopeWho is affectedAdministrator accessAppropriate use case
User PathOnly the current Windows accountUsually not requiredPython is intended for one user
System PathWindows users on the computerOften requiredPython 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

CommandExpected resultWhat it indicatesNext action
pythonInteractive Python prompt startsPATH found an interpreterUse exit() to leave, or run a version check
python --versionA Python version is printedThe python command resolves successfullyContinue using Python or inspect the selected file
where pythonOne or more executable pathsShows PATH-resolved Python files and their precedenceReview ordering if the wrong version runs
py --versionA launcher version is printedThe Python launcher is installedUse launcher options to select versions
C:\Python34\python.exe --versionA Python version is printedThe installation works when addressed directlyAdd its containing folder to PATH

Python folders that may need PATH entries

Folder purposeExample location patternWhen to add itCommands enabled
Python interpreter folderC:\Python34 or the folder containing python.exeRequired for the python commandpython and python --version
Scripts folderPython installation folder followed by ScriptsAdd when pip-installed command-line tools are not foundUtilities installed by pip
Per-user installationA Python directory under the current user's profileUse for an installation available to one accountThat user's interpreter and tools
System-wide installationA shared program directory or custom system folderUse when Python is installed for all usersInterpreter 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.exe exists in the directory you added.
  • Make sure you added the containing folder, not python.exe itself.
  • 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 python in the new terminal.

A different Python version starts

  • Run where python and inspect the order of the results.
  • Run py -0p if 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 python remains 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 pip so 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

  1. Find and verify python.exe.
  2. Run its full path with --version.
  3. Add the containing directory to User Path or System Path.
  4. Do not replace existing PATH entries.
  5. Optionally add the related Scripts directory for pip-installed commands.
  6. Open a new Command Prompt.
  7. Run python --version and where python.

For related command-line basics, see Python command line, installing Python on Windows, and running Python code.