{"id":"20c15285e5594440","repo":"python-poetry/poetry","slug":"wheel-filename-is-not-a-supported-wheel-for-this","errorCode":null,"errorMessage":"{wheel.filename} is not a supported wheel for this platform. It can't be sorted.","messagePattern":"(.+?) is not a supported wheel for this platform\\. It can't be sorted\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/poetry/installation/chooser.py","lineNumber":299,"sourceCode":"        Second, excepting hash considerations, candidates that have been\n        yanked (in the sense of PEP 592) are always less preferred than\n        candidates that haven't been yanked. Then:\n        If not finding wheels, they are sorted by version only.\n        If finding wheels, then the sort order is by version, then:\n          1. existing installs\n          2. wheels ordered via Wheel.support_index_min(self._supported_tags)\n          3. source archives\n        If prefer_binary was set, then all wheels are sorted above sources.\n        Note: it was considered to embed this logic into the Link\n              comparison operators, but then different sdist links\n              with the same version, would have to be considered equal\n        \"\"\"\n        build_tag: tuple[Any, ...] = ()\n        binary_preference = 0\n        if link.is_wheel:\n            wheel = Wheel(link.filename)\n            if not wheel.is_supported_by_environment(self._env):\n                raise RuntimeError(\n                    f\"{wheel.filename} is not a supported wheel for this platform. It \"\n                    \"can't be sorted.\"\n                )\n\n            # TODO: Binary preference\n            pri = -(wheel.get_minimum_supported_index(self._env.supported_tags) or 0)\n            if wheel.build_tag is not None:\n                match = re.match(r\"^(\\d+)(.*)$\", wheel.build_tag)\n                if not match:\n                    raise ValueError(f\"Unable to parse build tag: {wheel.build_tag}\")\n                build_tag_groups = match.groups()\n                build_tag = (int(build_tag_groups[0]), build_tag_groups[1])\n        else:  # sdist\n            support_num = len(self._env.supported_tags)\n            pri = -support_num\n\n        has_allowed_hash = int(self._is_link_hash_allowed_for_package(link, package))\n","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/installation/chooser.py#L281-L317","documentation":"Raised by Chooser._sort_key at src/poetry/installation/chooser.py:298-302 when link.is_wheel is True but Wheel(link.filename).is_supported_by_environment(self._env) returns False. Poetry refuses to even rank an incompatible wheel, surfacing the mismatch explicitly. RuntimeError.","triggerScenarios":"The candidate set includes a wheel whose tags (Python ABI, platform) do not match the target env — e.g. a cp39-manylinux wheel considered under a cp311-win32 interpreter. Triggered during install/update sorting when at least one link is a wheel.","commonSituations":"Wrong-platform wheel listed in the index (rare, but happens with mirrored legacy repos), an env mismatch ( Poetry running under a different Python than intended), or a transitive dependency that only ships platform wheels for other OSes.","solutions":["Confirm the active environment: `poetry env info` and check Python version/platform.","Switch to an env matching the wheel: `poetry env use python3.11` (or the relevant interpreter).","If the wheel is genuinely incompatible and shouldn't be listed, report it to the repository maintainer or restrict the source.","Prefer sources that also ship an sdist so Poetry can build for the current platform."],"exampleFix":"# before: poetry running under python3.9, package only has cp311 wheels\n$ poetry install\nRuntimeError: pkg-1.0-cp311-...whl is not a supported wheel...\n\n# after\n$ poetry env use python3.11\n$ poetry install","handlingStrategy":"validation","validationCode":"from poetry.utils.env import EnvManager\nfrom poetry.installation.wheel import Wheel\n\nenv = EnvManager.get_default_env()\nwheel = Wheel(link.filename)\nif not wheel.is_supported_by_environment(env):\n    raise ValueError(f'{link.filename} incompatible with env {env.marker_env}')","typeGuard":"def wheel_supported(filename: str, env) -> bool:\n    from poetry.installation.wheel import Wheel\n    return Wheel(filename).is_supported_by_environment(env)","tryCatchPattern":"try:\n    chooser._get_links(package)\nexcept RuntimeError as e:\n    if 'not a supported wheel' in str(e):\n        # switch env or restrict candidates\n        raise SystemExit('Switch to a compatible interpreter via `poetry env use`.') from e\n    raise","preventionTips":["Match the active interpreter to the platform/Python the wheels target.","In CI, run `poetry env use pythonX.Y` explicitly before install."],"tags":["wheel","platform","environment","installation","compatibility"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}