Navigation
Recherche
|
Get started with the new Python Installation Manager
mercredi 11 juin 2025, 11:00 , par InfoWorld
![]() But there’s been one long-standing weakness: While you have a central way to select which of your installed versions of Python to use for a given task, you can’t actually manage the installed versions. Python’s core development team has developed a new tool, the Python Installation Manager for Windows, to handle both of these functions: managing installed versions of Python, and choosing which version to use when launching Python. It’s currently only available as a pre-release, but as of Python 3.16, it’s intended to become the preferred way to manage and select Python installations in Windows. This article is a quick guide to getting started with the Python Installation Manager. Setting up the Python Installation Manager The Python Installation Manager is itself just another Windows app, so there are a few ways to install it: The Microsoft Store app offers a convenient one-click installation method. The official Python site offers a direct download, although this link is somewhat obscure and likely to change with each new release. You can also use the WinGet package manager: winget install 9NQ7512CXL7T. (Note that in the future, this alias may be changed to something more readable.) Python Installation Manager replaces ‘py’ If you used the earlier incarnation of the py tool for Python to manage Python versions, the Python Installation Manager eclipses its functionality. Typing py will now bring up the Python Installation Manager, although all the commands you used with py before will still work. If you want to see for yourself how things are different, open a command line and type py help. You’ll see the command list for the Python Installation Manager: IDG In the original py launcher, this command would have given an error. Now, it provides details about all the available command-line options for the Python Installation Manager. Adding and removing Python versions To see which versions of Python are already present in your system, type py list: IDG If you had Python instances installed before you set up the Python Installation Manager, you’ll be able to see them, but you won’t be able to change anything. If you want to make changes, you’ll need to manually remove the old instances (through the Apps pane in your Windows settings), then re-install them using the Python Installation Manager. In this case, the Python 3.14 instance shown in green (at the top of the screen) is managed by the Python Installation Manager; the others were added by hand earlier. Adding a version of Python is a simple command: py install: IDG Once installed, you can invoke that version by typing py -: IDG Removing a managed version of Python is equally simple: py uninstall: IDG To see which versions of Python are available through the manager, use py list --online. You can also export the listed Python installations as JSON if you want to feed it to other programs: py list -f=json. (CSV and JSONL formats are also available.) Setting the default Python When you list the available Python installations, one will typically be marked with an asterisk: IDG The asterisk indicates which version of Python is the default according to the Installation Manager. Just typing py brings up that version. But if you want to change it, you can set an environment variable. As an example, to set 3.12 as the default in PowerShell, you’d type: $Env:PYTHON_MANAGER_DEFAULT='3.12' After you set this, Python 3.12 will be listed as the default. IDG The pymanager alias It’s possible that a command like py install would clash with the name of a preconfigured command in a virtual environment, or with some other alias. To avoid that, you can use pymanager as an unambiguous name for the Python Installation Manager. All the commands remain the same; only the name of the executable is different. IDG Setting Python app aliases for Windows A possible final step is to configure the Windows app execution aliases for commands like python and python3. To do that, type py install --configure. You’ll then get a prompt to modify your system’s app execution aliases: IDG Typing “Y” opens the app execution aliases window in Settings. From there, you can change how python and python3 behave. If you toggle them off, as shown, they will no longer launch anything at the command line, but you can use py and pymanager to launch Python. That’s about it. One last thing worth noting is that we still have an active alias for pythonw and pyw. Those are special-case versions of the Python runtime that execute without a console session: IDG
https://www.infoworld.com/article/4001983/get-started-with-the-new-python-installation-manager.html
Voir aussi |
56 sources (32 en français)
Date Actuelle
ven. 13 juin - 12:56 CEST
|