In this post, various methods are demonstrated to add a Python path to the windows path. The content of this post is provided here:
- How to Add the Path of Python to Windows Path During Installation
- How to Add the Path of Python to Windows Path by Setting Path Environment Variable
- How to add the Path of Python to Windows Path Using Command Prompt
Method 1: How to Add Python into Windows Path During Installation?
Python is mostly used as a programming language for development purposes. During installation, we can add the Path of Python to the Windows path. Here are some steps mentioned that will be useful in Python installation.
Step 1: Download Python Setup file
Firstly, open the Python official website using mentioned link and download the Python latest available version by clicking on the Download Python button:
Step 2: Run Python Installer
Open the Downloads folder, start Python installation by double click on the Python setup file:
Step 3: Add Python to Windows Path
The Python setup file will display on the screen. To set Python to the Windows path, mark the “Add Python 3.10 to PATH” checkbox and hit the “Install Now” option:
We have successfully installed and added Python to Windows Path:
Step 4: Verify the path
Let us verify whether Python is added to the Windows path or not. To do so, open the “Edit the system environment variables” by searching it from taskbar:
Click on the “Environment Variables” option:
Select on the “Path” and click on “Edit”:
Here, you will find that the “Python310” path has been added:
You can see we have successfully installed and added the Python version “3.10.5” to the Windows path.
Method 2: How to Add Python to Windows Path by Setting Path Environment Variable?
Environment variables are primarily used to store information about Windows and tools that operate on it. It keeps complete track of the application version and installation path. We can add Python to the Windows path using the environment variables. To do so, follow the below-given steps:
Step 1: Open Python Installation Location
Open the directory where you have installed Python. Then, find the “python.exe” file:
Step 2: Copy Path
After finding the Python execution file, copy the path location from the address bar:
Step 3: Open Environment Variable Settings
Open the Environment Variable settings by searching it from the start menu:
From the “Advance” tab, click the “Environment Variables” button:
Step 4: Add Python to Windows
Choose the “Path” variable and hit the “Edit” button to add Python to the Windows path:
Upon doing so, the “Edit environment variable” Window will display on the screen. Press the “New” button, paste the path that we have copied, and hit the “Ok” button to save changes:
Step 5: Access Python From Command Line
Check out the python version from the Windows command line in order to check if the Python is added to the Windows path or not:
The above output indicates that we have successfully added Python to the Windows path.
Method 3: How to add Python to Windows Path Using Command Prompt?
Command Prompt is a well-known Windows command line user interface/shell. It can perform any operations that a user can do using GUI. Using CMD, we can add Python to Windows Path using Command Prompt. The following steps will add python to the windows path using the command prompt:
Step 1: Open Windows Command Prompt
Run the Windows Command Prompt as administrator by searching “Command Prompt” from the “Startup” menu:
Step 2: Add Python to Windows Path
Set Python Path environment variable using provided command. The below-provided command will set Python to the Windows path temporarily just for one section. Also, specify the Python installation path in the “Path” parameter as we have defined “C:\Python310”:
Alternatively, we can add Python to the Windows path permanently (means can be accessible whenever the user wants to use python) using the “setx” command:
We have effectively explained the different methods to add Python to the Windows path.
Conclusion
To access Python from the Windows command line, it is essential to add Python to the Windows path. We have explained different techniques that are effective enough to add Python to the Windows path. We can add Python to the Windows path during installation or we can add it manually by setting environment variables using GUI/command line. After setting the path, you can use Python from the command line.