{"id":"b418794cc77ca8d3","repo":"pypa/pip","slug":"failed-wheel-build-for-install","errorCode":"failed-wheel-build-for-install","errorMessage":"Failed to build installable wheels for some pyproject.toml based projects","messagePattern":"Failed to build installable wheels for some pyproject\\.toml based projects","errorType":"exception","errorClass":"InstallWheelBuildError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/build_env/installer.py","lineNumber":289,"sourceCode":"        from pip._internal.wheel_builder import build\n\n        ireqs = [install_req_from_line(req, user_supplied=True) for req in requirements]\n        ireqs.extend(self._build_constraints)\n\n        resolver = self._make_resolver()\n        resolved_set = resolver.resolve(ireqs, check_supported_wheels=True)\n        self._preparer.prepare_linked_requirements_more(\n            resolved_set.requirements.values()\n        )\n\n        reqs_to_build = [\n            r for r in resolved_set.requirements_to_install if not r.is_wheel\n        ]\n        _, build_failures = build(\n            reqs_to_build, self._wheel_cache, verify=True, allow_editables=True\n        )\n        if build_failures:\n            raise InstallWheelBuildError(build_failures)\n\n        installed = install_given_reqs(\n            resolver.get_installation_order(resolved_set),\n            prefix=prefix.path,\n            # Hard-coded options (that should NOT be inherited).\n            root=None,\n            home=None,\n            warn_script_location=False,\n            use_user_site=False,\n            # As the build environment is ephemeral, it's wasteful to\n            # pre-compile everything since not all modules will be used.\n            pycompile=False,\n            progress_bar=\"off\",\n            # Link console scripts to the build env's interpreter, not pip's.\n            script_executable=prefix.venv_executable,\n        )\n\n        env = get_environment(list(prefix.lib_dirs))","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/build_env/installer.py#L271-L307","documentation":"Raised by InprocessBuildEnvironmentInstaller._install_impl() at installer.py:289 when the build() call produces build failures for one or more pyproject.toml-based projects during in-process build dependency installation. The InstallWheelBuildError (reference: 'failed-wheel-build-for-install') lists the failed package names in its context.","triggerScenarios":"Using `pip install --use-feature=inprocess-build-deps <package>` where a build dependency (declared in pyproject.toml's build-system.requires) is a source distribution that fails to compile/build into a wheel. The reqs_to_build list at installer.py:282-284 collects non-wheel requirements, and build() returns failures at line 285-287.","commonSituations":"A build dependency like an old version of setuptools, Cython, or a C-extension package fails to compile due to missing system headers/compilers. Using inprocess-build-deps where a build dependency only has an sdist on PyPI. Platform mismatch (e.g., building Linux-only deps on macOS).","solutions":["Install the required system build tools (gcc, python3-dev, etc.) for the failing build dependency.","Remove `--use-feature=inprocess-build-deps` so pip uses standard subprocess isolation with better error reporting.","Pre-build wheels for the failing build dependency and make them available via --find-links.","Pin the build dependency to a version that ships pre-built wheels for your platform."],"exampleFix":"# before\npip install --use-feature=inprocess-build-deps mypkg\n# build dep fails to compile from sdist\n\n# after\npip install mypkg\n# or pre-install the build dep as a wheel:\npip install wheel && pip install mypkg","handlingStrategy":"validation","validationCode":"# Before installing, check if build deps have wheels for your platform:\n# pip index versions <build-dep> --only-binary=:all:\n# If no wheels, pre-install build tools (gcc, python-dev headers) first.","typeGuard":null,"tryCatchPattern":"from pip._internal.exceptions import InstallWheelBuildError\ntry:\n    # install logic\nexcept InstallWheelBuildError as e:\n    # e.reference == 'failed-wheel-build-for-install'\n    failed_names = str(e.context).split(\", \")\n    print(f\"Failed to build wheels for: {failed_names}\")\n","preventionTips":["Ensure system build tools (compiler, headers) are installed for packages with C extensions.","Use --only-binary=:all: when possible to avoid source builds.","Pre-build wheels for build dependencies in CI and serve via --find-links."],"tags":["wheel-build","pep517","build-isolation","inprocess-build-deps","compilation"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}