11

Currently, the latest Python 3 offered through winget is 3.10.150.0:

Name                                                Id                                 Version      Match                   Source
-----------------------------------------------------------------------------------------------------------------------------------
Python 3                                            Python.Python.3                    3.10.150.0   Command: python         winget

but I'd like to install 3.9 and keep using 3.9. Is it possible to do that with winget?

ccre
  • 422
  • 3
  • 10
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622

4 Answers4

13
winget install -e --id Python.Python -v 3.9.0
Tom McLean
  • 5,583
  • 1
  • 11
  • 36
4

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
x0lani
  • 41
  • 4
1

in Windows 11 i used the command in this site: https://winget.run/pkg/Python/Python.3

to get the version 3.7.7:

winget install -e --id Python.Python.3 -v 3.7.7150.0
0

Yes, winget can install an older version of Python. The most precise way to see the available versions is:

winget search --id Python.Python

This currently gives:

Name        Id                 Version   Source
------------------------------------------------
Python 2    Python.Python.2    2.7.18150 winget
Python 3    Python.Python.3.0  3.0.1     winget
Python 3    Python.Python.3.1  3.1.4     winget
Python 3    Python.Python.3.2  3.2.5     winget
Python 3    Python.Python.3.3  3.3.5     winget
Python 3    Python.Python.3.4  3.4.4     winget
Python 3    Python.Python.3.5  3.5.4     winget
Python 3    Python.Python.3.6  3.6.8     winget
Python 3    Python.Python.3.7  3.7.9     winget
Python 3    Python.Python.3.8  3.8.10    winget
Python 3    Python.Python.3.9  3.9.13    winget
Python 3.10 Python.Python.3.10 3.10.11   winget
Python 3.11 Python.Python.3.11 3.11.4    winget
Python 3.12 Python.Python.3.12 3.12.0b4  winget

So you can for example do winget install -e --id Python.Python.3.9.

This and more information about installing Python with winget can be found on https://winget.pro/winget-install-python/.

Michael Herrmann
  • 4,832
  • 3
  • 38
  • 53