Interested in learning how you can add Python to PATH on Windows? Let me teach you how!
How to Add Python to PATH on Windows?
Adding Python to the PATH environment variable on Windows allows you to run Python commands from any Command Prompt window or terminal. You can automatically add Python to PATH while installing Python.
In case you missed it, you can add it manually as well. To do so, follow these steps:
Step 1: Open Users Folder
On your system, go to “Local Disk C” and then to the “Users” folder:
Step 2: Open your Account Folder
Next, double-click on the folder with your system account name:
Step 3: Display Hidden Files
From the file explorer menu, hit on “View” and check the “Hidden items” box. As a result, a list of hidden files and folders will appear. Then, click on the “AppData” folder:
Step 4: Open Python Folder
Follow this path “AppData > Local > Programs > Python” to navigate to the Python folder:
Step 5: Open Version Specific Python Folder
After that, click on that specific Python version folder for which you want to add a PATH. In my case, it’s “Python312”:
Step 6: Copy Directory Address
Click on the breadcrumb navigation bar:
Now, copy this folder path:
Step 7: Add Python PATH to System Variables
Type “environment” in the Windows search bar and click on the “Edit the system environment variables” option:
After that, click on “Environment Variables”:
Double-click on “Path” from the “System variables” section:
Hit “New” and paste the folder path:
Optionally you can add the path to the “Scripts” folder if using Python tools like pip. For this click on the “New” button again, paste the same path, and add “\Scripts” at the end:
Once done click “OK”.
Step 8: Verify Environment Variable Settings
Open the command prompt, and type “python”. If you have an output like this then the changes are successfully applied:
Note: Reboot your system to make changes take effect (if required).
Conclusion
To add Python to PATH on Windows, navigate to that specific folder where Python is installed. Then, open the version-specific Python folder and copy the path to this folder.
Next, search “environment” in the Windows search bar, and click on the “Edit the system environment variables” option. Navigate to the system variables section and double-click “Path”. Hit “new” and paste the Python folder path you just copied.
Do check out this blog to create a virtual environment in Python.