First, you can see all the versions available with the following command:
PS C:\dev> winget search Python.Python
Name Id Version Source
---------------------------------------------
Python 3 Python.Python.3.9 3.9.7 winget
Python 3 Python.Python.3.8 3.8.10 winget
Python 3 Python.Python.3.7 3.7.9 winget
Python 3 Python.Python.3.6 3.6.8 winget
Python 3 Python.Python.3.5 3.5.4 winget
Python 3 Python.Python.3.4 3.4.4 winget
Python 3 Python.Python.3.3 3.3.5 winget
Python 3 Python.Python.3.2 3.2.5 winget
Python 3 Python.Python.3.10 3.10.6 winget
Python 3 Python.Python.3.1 3.1.4 winget
Python 3 Python.Python.3.0 3.0.1 winget
Python 2 Python.Python.2 2.7.18150 winget
In your case, the simplest way is to choose the Id you want, Python.Python.3.9, which would also allow the package manager to update it when patches come out.
PS C:\dev> winget install Python.Python.3.9
Found Python 3 [Python.Python.3.9] Version 3.9.7
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://www.python.org/ftp/python/3.9.7/python-3.9.7-amd64.exe
██████████████████████████████ 27.5 MB / 27.5 MB
Successfully verified installer hash
Starting package install...
Successfully installed
This will do an automatic install with default options. However, the downside of this method is that each Python version will be installed under a Python directory tree, like $LOCALAPPDATA\Programs\Python\Python39
, and it won't make any changes to your Path.
If you need Python to be available to all users and automatically added to the system Path, you're better off fine-tuning the installation using the interactive option -i, like so.
PS C:\dev> winget install -i Python.Python.3.9