sodcalculator

10 Tech How-To

How to Fix Python Not Working in Windows 11

Guide 10-58496 · Updated · Step by step

If Python is installed but won’t run on Windows 11 — commands like python or pip return errors, or nothing happens — this guide walks you through the most common fixes. You’ll learn how to diagnose the issue, correct your PATH, reinstall cleanly, and handle environment problems.

What You’ll Need

  • A Windows 11 PC with administrator access (to install or modify system settings).
  • The official Python installer (if a reinstall is needed) from python.org.
  • An internet connection for downloading updates or packages.

Step-by-Step

  1. Check if Python is actually installed.
    Open Command Prompt (press Win, type cmd, press Enter). Type python --version and press Enter. If you see something like Python 3.12.1, Python is installed. If you get 'python' is not recognized, it’s either not installed or not in your PATH.
  2. Check the Python installation folder.
    If the command fails, look for Python manually. Open File Explorer and navigate to C:\Users\YourUserName\AppData\Local\Programs\Python (if installed per-user) or C:\Python (if installed system-wide). If you find a folder like Python312, note the full path.
  3. Use the Windows App execution alias.
    Windows 11 has built-in aliases for Python that can interfere. Go to Settings > Apps > Advanced app settings > App execution aliases. Look for python.exe and python3.exe. If they are enabled, disable them, then try python --version again. These aliases often point to the Microsoft Store stub, which doesn’t work as expected.
  4. Check the PATH environment variable.
    In the Start menu, search for “environment variables” and select Edit the system environment variables. Click Environment Variables. In the User variables or System variables, select Path and click Edit. Ensure the Python installation folder (e.g., C:\Users\YourName\AppData\Local\Programs\Python\Python312) and its Scripts subfolder (e.g., ...\Python312\Scripts) are listed. If not, add them. Click OK to save.
  5. Try the py launcher.
    Windows often installs the Python launcher. In Command Prompt, type py --version. If that works, you can use py instead of python for all commands. To make python work too, you can add py as an alias or use the full path.
  6. Repair or reinstall Python.
    If nothing works, reinstall Python. Download the latest stable version from python.org. Run the installer. Important: Check the box “Add Python to PATH” at the bottom of the first screen. Then click Install Now. After installation, restart Command Prompt and test again.
  7. Check for multiple Python installations.
    If you have both the Microsoft Store version and the official one, they can conflict. Uninstall the Microsoft Store version via Settings > Apps > Installed apps. Keep only the official one.
  8. Test pip.
    Once python --version works, type pip --version. If pip is not recognized, use python -m pip --version. If that works, you can use python -m pip for all package installs.
  9. Open a new terminal.
    After any PATH change, close and reopen Command Prompt or PowerShell. Old sessions keep the old PATH.

Common Mistakes

  • Not checking “Add Python to PATH” during installation. This is the #1 reason Python doesn’t work after installation.
  • Editing the wrong PATH variable. Make sure you add the correct folder path, and don’t accidentally delete existing entries.
  • Using the Microsoft Store alias. The aliases in Windows 11 can cause confusion; disabling them often fixes the issue.
  • Forgetting to restart the terminal. PATH changes only apply to new sessions.
  • Having both 32-bit and 64-bit Python. Uninstall one to avoid conflicts.

Tips

  • Use the py launcher if you have multiple Python versions; it lets you specify py -3.11 or py -3.12.
  • Create a virtual environment for each project to avoid package conflicts: python -m venv myenv.
  • Run where python in Command Prompt to see which Python executable is being used.
  • Keep Python updated to the latest patch version to avoid known bugs.

Troubleshooting

If python --version still fails after following the steps:

  • Check the exact error message. If it says Access is denied, run Command Prompt as administrator.
  • If you see Python was not found; run without arguments to install from the Microsoft Store, the alias is still active. Revisit Step 3 and disable both aliases.
  • If you manually added the PATH but it still doesn’t work, double-check the folder name. It might be Python313 instead of Python312.
  • Try running C:\Users\YourName\AppData\Local\Programs\Python\Python312\python.exe --version directly. If that works, the PATH is wrong.
  • If the installer fails, run it in compatibility mode: right-click the installer, select Properties > Compatibility, and run as administrator.
  • If you have a corporate or managed PC, group policy might block Python. Contact your IT admin.

If Python works but pip doesn’t:

  • Run python -m pip install --upgrade pip to fix pip itself.
  • If you get a ModuleNotFoundError, your Python installation is corrupted. Reinstall.

Frequently Asked Questions

Why does Windows 11 open the Microsoft Store when I type “python”?

This happens because the App execution alias is enabled. Disable it in Settings > Apps > Advanced app settings > App execution aliases.

Is Python preinstalled on Windows 11?

No, Windows 11 does not come with Python. You need to install it manually, either from the Microsoft Store or from python.org.

Should I install Python from the Microsoft Store?

It’s possible, but the official python.org installer gives you more control over PATH and installation location. For most users, the official installer is recommended.

How do I add Python to PATH manually?

Go to System Properties > Environment Variables, find the Path variable, edit it, and add the full path to your Python folder (e.g., C:\Users\YourName\AppData\Local\Programs\Python\Python312) and its Scripts subfolder.

Why does my Python script run but immediately close?

That’s normal when you double-click a .py file. Add input() at the end of the script, or run it from Command Prompt to see the output.

Can I have multiple Python versions installed?

Yes, but use the py launcher to select which one runs. For example, py -3.11 runs Python 3.11.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →