{"record":{"id":"ae672889a67a25d7","repo":"microsoft/autogen","slug":"pip-install-failed-stdout-decode-stderr-dec","errorCode":null,"errorMessage":"Pip install failed. {stdout.decode()}, {stderr.decode()}","messagePattern":"Pip install failed\\. (.+?), (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/code_executors/local/__init__.py","lineNumber":312,"sourceCode":"                asyncio.create_subprocess_exec(\n                    py_executable,\n                    *cmd_args,\n                    cwd=self.work_dir,\n                    stdout=asyncio.subprocess.PIPE,\n                    stderr=asyncio.subprocess.PIPE,\n                )\n            )\n            cancellation_token.link_future(task)\n            try:\n                proc = await task\n                stdout, stderr = await asyncio.wait_for(proc.communicate(), self._timeout)\n            except asyncio.TimeoutError as e:\n                raise ValueError(\"Pip install timed out\") from e\n            except asyncio.CancelledError as e:\n                raise ValueError(\"Pip install was cancelled\") from e\n\n            if proc.returncode is not None and proc.returncode != 0:\n                raise ValueError(f\"Pip install failed. {stdout.decode()}, {stderr.decode()}\")\n\n        # Attempt to load the function file to check for syntax errors, imports etc.\n        exec_result = await self._execute_code_dont_check_setup(\n            [CodeBlock(code=func_file_content, language=\"python\")], cancellation_token\n        )\n\n        if exec_result.exit_code != 0:\n            raise ValueError(f\"Functions failed to load: {exec_result.output}\")\n\n        self._setup_functions_complete = True\n\n    async def execute_code_blocks(\n        self, code_blocks: List[CodeBlock], cancellation_token: CancellationToken\n    ) -> CommandLineCodeResult:\n        \"\"\"(Experimental) Execute the code blocks and return the result.\n\n        Args:\n            code_blocks (List[CodeBlock]): The code blocks to execute.","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/code_executors/local/__init__.py#L294-L330","documentation":"Raised during LocalCommandLineCodeExecutor function setup when the pip install subprocess exits with a nonzero return code. The message embeds both decoded stdout and stderr of pip, so the actual pip failure (resolution error, no network, bad package name) is visible in the exception text.","triggerScenarios":"Registering functions with @register_function whose imports name packages that cannot be resolved or installed (typos, private packages without credentials), offline environments where pip cannot reach PyPI, or Python version incompatibilities of the requested packages.","commonSituations":"Typo'd package names in imports (e.g. 'numpyy'), corporate networks blocking PyPI, private index auth missing, packages without wheels for the running Python version, mismatch between the executor's virtual_env_context Python and package requirements.","solutions":["Read the embedded pip stderr in the exception - it names the failing package and reason; fix the import name or pin a compatible version.","If offline, pre-install the packages in the target environment or configure an index URL the executor's environment uses.","For private packages, configure credentials (PIP_INDEX_URL, keyring) in the environment the executor shells out to."],"exampleFix":"# before\n@register_function\ndef summarize(text: str) -> str:\n    import numpyy  # typo -> pip install fails -> ValueError: Pip install failed.\n    ...\n\n# after\n@register_function\ndef summarize(text: str) -> str:\n    import numpy\n    ...","handlingStrategy":"try-catch","validationCode":"import subprocess, sys\n\ndef deps_installable(pkgs: list[str]) -> bool:\n    r = subprocess.run([sys.executable, \"-m\", \"pip\", \"install\", \"--dry-run\", *pkgs], capture_output=True)\n    return r.returncode == 0","typeGuard":null,"tryCatchPattern":"try:\n    await executor.execute_code_blocks(blocks, token)\nexcept ValueError as e:\n    if \"Pip install failed\" in str(e):\n        log.error(\"pip failed during setup: %s\", str(e))  # stdout/stderr embedded\n        raise\n    raise","preventionTips":["Double-check import spelling in registered functions.","Pre-install or vendor private dependencies; configure PIP_INDEX_URL for private indexes.","Run pip install --dry-run in CI to validate dependency lists early."],"tags":["pip","dependencies","local-executor","setup"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}