python-discovery¶
You may have multiple Python versions installed on your machine – system Python, versions from
pyenv, mise,
asdf, uv, or the Windows registry
(PEP 514). python-discovery finds the right one for you.
Give it a requirement like python3.12 or >=3.11,<3.13, and it searches all known locations,
verifies each candidate, and returns detailed metadata about the match. Results are cached to disk so
repeated lookups are fast.
frompathlibimport Path frompython_discoveryimport DiskCache, get_interpreter cache = DiskCache(root=Path("~/.cache/python-discovery").expanduser()) result = get_interpreter("python3.12", cache=cache) if result is not None: print(result.executable) # /usr/bin/python3.12 print(result.implementation) # CPython print(result.version_info[:3]) # (3, 12, 1)
