py3versions
List installed Python 3 versions
SYNOPSIS
py3versions [OPTION]... [VERSIONS]
PARAMETERS
-v, --verbose
Print versions in a more verbose format, e.g., 'Python 3.x is available.' Each line includes a descriptive message.
-r, --requirements
Print versions in a format suitable for requirements.txt files, e.g., 'python3.x'. Useful for specifying interpreter dependencies.
-p, --print-path
Print the full absolute path to the Python 3 interpreter executable for each detected version. This helps in directly invoking a specific Python version.
[VERSIONS]
Optional. A space-separated list of Python 3 versions to check for availability. If provided, py3versions will only print versions from this list that are actually installed on the system.
DESCRIPTION
py3versions is a utility predominantly found on Debian-based Linux distributions (like Ubuntu) that helps identify and list the installed Python 3 interpreter versions. It's often used by maintainer scripts of Python packages to determine which Python 3 versions are available for building or installation. The command lists each detected version on a new line, allowing for easy parsing by other scripts.
It can also format the output for requirements.txt files or print the full paths to the interpreters. This tool simplifies the process of managing multiple Python 3 installations, ensuring compatibility and proper execution of Python applications across different environments by providing a standardized way to query available versions.
CAVEATS
py3versions is primarily a Debian/Ubuntu specific utility and may not be available on other distributions (e.g., Fedora, CentOS, Arch) or might have different behavior. It relies on the standard Python packaging conventions of the distribution; custom Python installations (e.g., via pyenv, conda, or source compilation outside of system paths) might not be detected unless symlinked into standard locations.
ENVIRONMENT VARIABLES
The behavior of py3versions can be influenced by environment variables:
PY3VERSIONS_PRINT_PATH: If this variable is set to any value, it effectively enables the functionality of the --print-path option, causing the command to output full interpreter paths.
PYBUILD_SYSTEM: While not directly controlling py3versions, this variable relates to pybuild, which uses similar logic for Python version detection, indicating the underlying dependency on this utility for consistent build environments.
HISTORY
py3versions emerged as part of the Debian Python packaging efforts, particularly with the transition and co-existence of Python 2 and Python 3. It was designed to standardize how system-wide Python 3 versions are identified and managed by package maintainers. Its development is intertwined with the python3-defaults and python3-minimal packages, providing a stable API for scripts to query available interpreters without hardcoding version numbers, which became crucial as Python 3.x releases continued to evolve. This utility ensures that Python packages can correctly target and utilize the appropriate Python 3 interpreters available on a system.
SEE ALSO
python(1), python3(1), pybuild(1), update-alternatives(8)