WinGet Python: Install Python on Windows
Install Python on Windows directly with the Windows Package Manager (WinGet) command. This can be done directly through the Windows Terminal or PowerShell without downloading the Python installer from the Web or visiting the Microsoft Windows Store.
Search WinGet for the Python Package
You can easily search for Python packages available for installation on Windows with the winget search command, this will list the available Python packages and their versions.
winget search python.python
Install Python with WinGet
To install Python on Windows, you can use the Windows Package Manager (WinGet) install command.
winget install python.python.3.12
This command will go through the downloading and full installation of Python once the installation is complete, run the following command to refresh the Windows $env:Path variable, which will give us Terminal access to the Python executable.
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
We can also check the source of python.exe by running the PowerShell Get-Command.
Get-Command python.exe
Once the $env:Path variable is refreshed, you can directly call python.exe from the terminal to open a Python IDLE shell.
python.exe
We also want to make sure that pip.exe is installed and accessible. This important application is responsible for Python package management. Run the PowerShell Get-Command on this application as well.
Get-Command pip.exe
To check the version of pip, we can use the pip --version command.
pip --version
Once you have verified the Python IDLE environment, Python pip, and have access to the python.exe and pip.exe in your $env:Path variable you are ready to program with Python on Windows!
If you like what you see check out my other great blog articles!