{"id":"d057f8b0f4c86c73","repo":"pypa/pip","slug":"for-req-req-description-e-args-0","errorCode":null,"errorMessage":"For req: {req_description}. {e.args[0]}","messagePattern":"For req: (.+?)\\. (.+?)","errorType":"exception","errorClass":"InstallationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/operations/install/wheel.py","lineNumber":738,"sourceCode":"    )\n\n    # Record details of all files installed\n    record_path = os.path.join(dest_info_dir, \"RECORD\")\n\n    with _generate_file(record_path, **csv_io_kwargs(\"w\")) as record_file:\n        # Explicitly cast to typing.IO[str] as a workaround for the mypy error:\n        # \"writer\" has incompatible type \"BinaryIO\"; expected \"_Writer\"\n        writer = csv.writer(cast(\"IO[str]\", record_file))\n        writer.writerows(_normalized_outrows(rows))\n\n\n@contextlib.contextmanager\ndef req_error_context(req_description: str) -> Generator[None, None, None]:\n    try:\n        yield\n    except InstallationError as e:\n        message = f\"For req: {req_description}. {e.args[0]}\"\n        raise InstallationError(message) from e\n\n\ndef install_wheel(\n    name: str,\n    wheel_path: str,\n    scheme: Scheme,\n    req_description: str,\n    pycompile: bool = True,\n    warn_script_location: bool = True,\n    direct_url: DirectUrl | None = None,\n    requested: bool = False,\n    script_executable: str | None = None,\n) -> None:\n    with ZipFile(wheel_path, allowZip64=True) as z:\n        with req_error_context(req_description):\n            _install_wheel(\n                name=name,\n                wheel_zip=z,","sourceCodeStart":720,"sourceCodeEnd":756,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/operations/install/wheel.py#L720-L756","documentation":"This is not a standalone error but the req_error_context() context manager (wheel.py:732-738) that wraps _install_wheel. It catches any InstallationError raised during the install of a wheel and re-raises a new InstallationError prefixed with 'For req: <description>. ', so the user sees which requirement caused the inner failure (e.g. a MissingCallableSuffix, path-traversal, or scheme error).","triggerScenarios":"Any InstallationError raised inside _install_wheel (called from install_wheel) is caught and re-tagged with the req_description. The original exception is chained via 'from e'. The visible message is the inner error's args[0] with the requirement name prepended.","commonSituations":"Any of the wheel-install errors (102-106) occurring during a pip install of a specific requirement; the wrapper surfaces the requirement name so you know which package's wheel is broken.","solutions":["Read the message after 'For req:' to identify which requirement's wheel failed, then read the inner message (and the chained exception) for the root cause.","Apply the fix corresponding to the underlying error (entry point, path traversal, scheme key, .data layout).","Rebuild/reinstall that specific requirement in isolation: pip install --force-reinstall --no-deps <that-req>.","Pin or upgrade/downgrade the problematic requirement to a version with a valid wheel."],"exampleFix":"# the message reads:\n# For req: mypkg. Invalid script entry point: mypkg.cli ...\n# fix the entry point in mypkg's build config, then:\npip install --force-reinstall --no-deps ./mypkg-1.0-py3-none-any.whl","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from pip._internal.exceptions import InstallationError\ntry:\n    install_wheel(name, wheel_path, scheme, req_description)\nexcept InstallationError as e:\n    # e.__cause__ holds the original inner error (MissingCallableSuffix, etc.)\n    logger.error(\"install of %s failed: %s\", req_description, e.__cause__)\n    raise","preventionTips":["Always inspect e.__cause__ to find the underlying wheel error, not just the wrapped message.","Validate the wheel (entry points, paths, scheme keys) before calling install_wheel.","Install requirements one at a time to localize which wheel is broken."],"tags":["wheel","install","error-context","packaging"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}