Typing python in your Windows 11 command prompt may result in an error message like "Python is not recognized as an internal or external command." This happens because Windows doesn't know where to find your Python installation. To fix this, you need to add Python to your PATH environment variable.

Using System Properties to Add Python to PATH

Step 1: Locate your Python installation folder. Usually, Python is installed in a directory like C:\Users\YourUsername\AppData\Local\Programs\Python\Python311 (for Python 3.11). If you're unsure, open File Explorer and search for python.exe. Once found, click on the address bar at the top of File Explorer and copy the full path to your Python installation.

Step 2: Open the Environment Variables window. To do this, press Win + S and type Edit the system environment variables, then press Enter. This opens the System Properties window. Now click on the Environment Variables button at the bottom.

Step 3: In the Environment Variables window, under the User variables section, select the variable named Path and click Edit. If you don't see a Path variable, click New and create one named Path.

Step 4: In the Edit environment variable window, click New and paste the Python installation path you copied earlier. Press Enter to confirm.

Step 6: Next, add another entry for the Scripts directory located inside your Python installation folder. Typically, this will look like C:\Users\YourUsername\AppData\Local\Programs\Python\Python311\Scripts.

Step 5: Confirm your changes by clicking OK on all open windows. To ensure the changes take effect, close any open command prompts and open a new one. Type python --version into the command prompt to verify the installation was successful.


Add Python to PATH Automatically During Installation

If you haven't yet installed Python or prefer a simpler approach, you can automatically add Python to PATH during the installation process.

Step 1: Download the latest Python installer from the official Python website. Run the installer once downloaded.

Step 2: In the installer window, you'll see an option labeled Add Python to PATH at the bottom. Make sure you check this box before clicking Install Now.

Step 3: After installation finishes, open a new command prompt window and type python --version to confirm Python is correctly added to your PATH.


Using the Command Line to Edit PATH (Advanced Method)

If you're comfortable with command-line operations, you can add Python to PATH directly from the command prompt.

Step 1: Open the Start menu, type cmd, and choose Run as administrator.

Step 2: To add Python to the system PATH, execute the following command (replace the path below with your actual Python installation path):

setx PATH "%PATH%;C:\Users\YourUsername\AppData\Local\Programs\Python\Python311;C:\Users\YourUsername\AppData\Local\Programs\Python\Python311\Scripts" /M

This command permanently adds Python and its Scripts directory to the system-wide PATH variable. After running this command, restart your command prompt window to apply the changes.


With Python properly added to your Windows 11 PATH, you can now run Python commands from any command prompt without specifying the full path. Happy coding!