Skip to content

Windows: Use the Python Launcher to Select Python Version #940

@danyeaw

Description

@danyeaw

In macOS and Linux, pipx allows you to set the Python version using the --python option. For example, pipx install --python python3.11 black. However, in Windows, all Python executables are named python.exe. So the only solution I have found to tell pipx the interpreter is by giving the full path like:

pipx install --python 'C:\\Users\\dan\\AppData\\Local\\Programs\\Python\\Python311\\python.exe' black

The standard way to select a Python version in Windows is with the Python Launcher. For example, py -3.11, will launch Python 3.11. It is possible to use the launcher with pipx with pipx install --python py black. However, I don't see a way to tell py which version of Python to use.

How would this feature be useful?
In Windows on GitHub Actions, pipx is installed by default with Python 3.9. I would like to run the setup-python action and then tell pipx to use this later Python version.

Describe the solution you'd like
pipx install --python 3.11 black would use py -3.11 on Windows and python3.11 in Linux/macOS. An alternative might be --python py311 which is the format tox uses.

Describe alternatives you've considered
Reinstall pipx for each Python version, or use the full path to the Python executable.

I would be glad to help implement this if there is agreement that this would be a nice enhancement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions