{"record":{"id":"2521a8c18044bece","repo":"microsoft/autogen","slug":"pip-install-timed-out","errorCode":null,"errorMessage":"Pip install timed out","messagePattern":"Pip install timed out","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/code_executors/local/__init__.py","lineNumber":307,"sourceCode":"                py_executable = self._virtual_env_context.env_exe\n            else:\n                py_executable = sys.executable\n\n            task = asyncio.create_task(\n                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","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/code_executors/local/__init__.py#L289-L325","documentation":"Raised during LocalCommandLineCodeExecutor's lazy function setup: the pip install subprocess (installing dependencies extracted from registered functions) exceeded self._timeout seconds while communicating, so asyncio.wait_for cancelled it and the ValueError wraps the asyncio.TimeoutError.","triggerScenarios":"Registering functions whose dependencies trigger a large pip install (numpy, torch, etc.) while timeout is small (e.g. the 60s default); slow networks or cold pip caches make proc.communicate() exceed the executor timeout on the first execute_code_blocks call.","commonSituations":"First execution after construction with heavy dependencies (setup is deferred to the first code block), CI with cold caches, restricted networks where PyPI is slow, default 60s timeout with torch/transformers installs.","solutions":["Increase the executor's timeout (e.g. timeout=600) so setup has room for the pip install.","Pre-install heavy dependencies into the environment the executor uses (its virtual_env_context or the interpreter running the app) so pip is a no-op.","Warm the pip cache or use a local index mirror to speed the install."],"exampleFix":"# before\nexecutor = LocalCommandLineCodeExecutor(timeout=60)\n# first execute_code_blocks triggers pip install of torch -> ValueError: Pip install timed out\n\n# after\nexecutor = LocalCommandLineCodeExecutor(timeout=600)","handlingStrategy":"validation","validationCode":"HEAVY = {\"torch\", \"tensorflow\", \"transformers\", \"numpy\", \"pandas\"}\n\ndef needs_generous_timeout(imports: set[str]) -> bool:\n    return bool(imports & HEAVY)","typeGuard":null,"tryCatchPattern":"try:\n    await executor.execute_code_blocks(blocks, token)\nexcept ValueError as e:\n    if \"Pip install timed out\" in str(e):\n        executor = LocalCommandLineCodeExecutor(timeout=600, functions=functions)\n        await executor.execute_code_blocks(blocks, CancellationToken())\n    else:\n        raise","preventionTips":["Pre-install heavy dependencies in the target interpreter so setup's pip is a no-op.","Set a generous timeout when functions import large packages.","Warm pip caches in CI before first execution."],"tags":["pip","timeout","local-executor","setup"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}