{"record":{"id":"31301ab1fa2708de","repo":"microsoft/autogen","slug":"pip-install-failed-stdout-stderr","errorCode":null,"errorMessage":"Pip install failed. {stdout}, {stderr}","messagePattern":"Pip install failed\\. (.+?), (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/code_executors/docker/_docker_code_executor.py","lineNumber":275,"sourceCode":"        func_file.write_text(func_file_content)\n\n        # Collect requirements\n        lists_of_packages = [x.python_packages for x in self._functions if isinstance(x, FunctionWithRequirements)]\n        flattened_packages = [item for sublist in lists_of_packages for item in sublist]\n        required_packages = list(set(flattened_packages))\n        if len(required_packages) > 0:\n            logging.info(\"Ensuring packages are installed in executor.\")\n\n            packages = shlex.join(required_packages)\n\n            result = await self._execute_code_dont_check_setup(\n                [CodeBlock(code=f\"python -m pip install {packages}\", language=\"sh\")], cancellation_token\n            )\n\n            if result.exit_code != 0:\n                stdout = result.output\n                stderr = result.output\n                raise ValueError(f\"Pip install failed. {stdout}, {stderr}\")\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 _kill_running_command(self, command: List[str]) -> None:\n        if self._container is None or not self._running:\n            return\n        await asyncio.to_thread(self._container.exec_run, [\"pkill\", \"-f\", \" \".join(command)])\n\n    async def _execute_command(self, command: List[str], cancellation_token: CancellationToken) -> Tuple[str, int]:\n        if self._container is None or not self._running:","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/code_executors/docker/_docker_code_executor.py#L257-L293","documentation":"Raised during Docker executor setup (_setup_functions) when `python -m pip install <packages>` executed inside the container exits non-zero. The packages come from the `required_packages` lists of the functions passed to the constructor. The message embeds the command output (note: an upstream quirk sets both stdout and stderr fields to result.output).","triggerScenarios":"First execute_code_blocks call when any function declares required_packages that pip cannot install in the container: package name typo, no network access in the container, incompatible Python version in the image, or an unpublished/unpinned dependency that breaks resolution.","commonSituations":"Containers without internet (corporate networks, --network none); pinning a package version with no wheel for the image's Python/arch (e.g. numpy on python:3-slim arm64); typo'd package names like 'pandasq'; proxy env vars not passed into the container.","solutions":["Read the embedded pip output — it is the real pip error (resolution failure, network error, no matching distribution)","Fix the package spec in the function's required_packages (correct name/pin) and retry","If the container has no network, pre-install dependencies into a custom image and pass image=\"that-image\" instead of relying on runtime pip","For proxy environments, build the pip config into the image (ENV PIP_INDEX_URL=...) since the executor does not forward host proxy settings"],"exampleFix":"# before\nDockerCommandLineCodeExecutor(functions=[(fn, [\"pandas==9.9.9\"])])  # nonexistent version\n\n# after\nDockerCommandLineCodeExecutor(functions=[(fn, [\"pandas>=2.0\"])])\n\n# or bake deps into an image:\n# Dockerfile: FROM python:3-slim / RUN pip install pandas\nDockerCommandLineCodeExecutor(image=\"my-executor:latest\", functions=[fn])","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try:\n    await executor.execute_code_blocks(blocks, ct)\nexcept ValueError as e:\n    if \"Pip install failed\" in str(e):\n        # str(e) contains pip's real output: resolution error, network error, etc.\n        fix_required_packages_from_pip_output(str(e))\n        executor = DockerCommandLineCodeExecutor(functions=fixed_functions)\n        await executor.execute_code_blocks(blocks, ct)","preventionTips":["Pre-install heavy dependencies into a custom executor image instead of runtime pip","Pin versions that have wheels for the image's Python version and architecture","Ensure containers have network/proxy access before relying on runtime pip"],"tags":["docker","pip","dependencies","network"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}