findpython
findpython is a Python utility library designed to locate various Python versions installed on your system. It is a modern rewrite of the `pythonfinder` project, simplifying the codebase while retaining core functionality. The current version is 0.7.1, and the project maintains an active release cadence with frequent bug fixes and feature enhancements.
Warnings
- breaking Version 0.5.0 dropped official support for Python 3.7. Users on Python 3.7 should either upgrade their Python environment or pin findpython to a version older than 0.5.0.
- gotcha As of version 0.6.3, `findpython` prefers 64-bit Python interpreters over 32-bit ones when both are available and meet other criteria. This might alter the expected result if your system has mixed architectures and you rely on a specific 32-bit interpreter.
- gotcha Version 0.7.0 introduced a feature to separate free-threaded Python versions from normal ones. While not strictly 'breaking', this change means that the `PythonVersion` objects returned might now include an indication of whether an interpreter is free-threaded, which could affect how you filter or interpret the results if you have such environments.
- gotcha The library searches for Python in various locations including PATH, pyenv, asdf, rye, uv, macOS Frameworks, and Windows registry. The order of preference can be complex, and `findpython` might not always return the exact Python you expect if multiple versions are present and configured differently across these sources.
Install
-
pip install findpython
Imports
- findpython
import findpython
- PythonVersion
from findpython.python_version import PythonVersion
Quickstart
import findpython
# Find all Python versions on the system
pythons = findpython.find_pythons()
for p in pythons:
print(f"Found Python: {p.executable} (Version: {p.major}.{p.minor}.{p.patch}, 64bit: {p.is_64bit})")
# Find a specific Python version (e.g., Python 3.9)
py39 = findpython.find_python(3, 9)
if py39:
print(f"Found Python 3.9: {py39.executable}")
else:
print("Python 3.9 not found.")