{"id":"4af4026feb5c2649","repo":"python-poetry/poetry","slug":"poetry-was-unable-to-find-a-compatible-version-if","errorCode":null,"errorMessage":"Poetry was unable to find a compatible version. If you have one, you can explicitly use it via the \"env use\" command.","messagePattern":"Poetry was unable to find a compatible version\\. If you have one, you can explicitly use it via the \"env use\" command\\.","errorType":"exception","errorClass":"NoCompatiblePythonVersionFoundError","httpStatus":null,"severity":"error","filePath":"src/poetry/utils/env/python/manager.py","lineNumber":323,"sourceCode":"        :param poetry: The poetry configuration containing package information,\n                       including Python constraints.\n        :param io: The input/output stream for error and status messages. Defaults\n                   to a null I/O if not provided.\n        :return: A Python instance representing a compatible Python version.\n        :raises NoCompatiblePythonVersionFoundError: If no Python version matches\n                the supported constraint.\n        \"\"\"\n        io = io or NullIO()\n        supported_python = poetry.package.python_constraint\n\n        for python in cls.find_all():\n            if python.version.allows_any(supported_python):\n                io.write_error_line(\n                    f\"Using <c1>{python.name}</c1> ({python.patch_version})\"\n                )\n                return python\n\n        raise NoCompatiblePythonVersionFoundError(poetry.package.python_versions)\n","sourceCodeStart":305,"sourceCodeEnd":324,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/utils/env/python/manager.py#L305-L324","documentation":"Raised as NoCompatiblePythonVersionFoundError (no 'given') in PythonManager.get_compatible_python when none of the discovered Python candidates (Python.find_all()) allows the project's python constraint. This is the auto-resolution fallback path: Poetry tried to find any interpreter that fits and failed.","triggerScenarios":"Calling Python.get_compatible_python(poetry, io) - reached from create_venv when the preferred python is incompatible and no specific one was requested - and the loop at manager.py:316-321 finds zero matching candidates.","commonSituations":"Project requires python >=3.11 but only 3.9/3.10 are installed/on PATH; no system python at all; all discovered interpreters fail the constraint; a CI image provisioned with the wrong python versions.","solutions":["Install a Python that satisfies the constraint: 'poetry python install <version>' or system/pyenv.","Loosen the python constraint in pyproject.toml to match an available interpreter.","Explicitly point to one you have: 'poetry env use <path-to-compliant-python>'.","Verify what Poetry can see: 'poetry python list' to enumerate discovered candidates."],"exampleFix":"// before - only 3.9 available, project needs >=3.11\n# poetry install -> falls through to get_compatible_python -> raise\n\n// after\n# poetry python install 3.12  (or loosen the constraint)\npoetry install","handlingStrategy":"validation","validationCode":"from poetry.utils.env.python import Python\n\ndef any_compatible_python(poetry) -> bool:\n    constraint = poetry.package.python_constraint\n    return any(p.version.allows_any(constraint) for p in Python.find_all())","typeGuard":"from poetry.utils.env.python.exceptions import NoCompatiblePythonVersionFoundError, PythonVersionError\n\ndef is_no_compatible_python(e: Exception) -> bool:\n    return isinstance(e, NoCompatiblePythonVersionFoundError) or (\n        isinstance(e, PythonVersionError) and \"unable to find a compatible version\" in str(e)\n    )","tryCatchPattern":"from poetry.utils.env.python.exceptions import NoCompatiblePythonVersionFoundError\n\ntry:\n    Python.get_compatible_python(poetry=poetry, io=io)\nexcept NoCompatiblePythonVersionFoundError:\n    # install one or widen the constraint\n    run_cli([\"poetry\", \"python\", \"install\", earliest_allowed(poetry)])","preventionTips":["Keep at least one interpreter installed that satisfies the project's python constraint.","List candidates with 'poetry python list' / 'poetry env list' to verify availability.","Loosen [tool.poetry.dependencies] python if a wider range is acceptable.","Provision CI images with a python version inside the project's constraint."],"tags":["python-constraint","compatibility","interpreter","pyproject"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}