microsoft/autogen · error · ValueError
Pip install timed out
Error message
Pip install timed out
What it means
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.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/code_executors/local/__init__.py:307
py_executable = self._virtual_env_context.env_exe
else:
py_executable = sys.executable
task = asyncio.create_task(
asyncio.create_subprocess_exec(
py_executable,
*cmd_args,
cwd=self.work_dir,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
)
cancellation_token.link_future(task)
try:
proc = await task
stdout, stderr = await asyncio.wait_for(proc.communicate(), self._timeout)
except asyncio.TimeoutError as e:
raise ValueError("Pip install timed out") from e
except asyncio.CancelledError as e:
raise ValueError("Pip install was cancelled") from e
if proc.returncode is not None and proc.returncode != 0:
raise ValueError(f"Pip install failed. {stdout.decode()}, {stderr.decode()}")
# Attempt to load the function file to check for syntax errors, imports etc.
exec_result = await self._execute_code_dont_check_setup(
[CodeBlock(code=func_file_content, language="python")], cancellation_token
)
if exec_result.exit_code != 0:
raise ValueError(f"Functions failed to load: {exec_result.output}")
self._setup_functions_complete = True
async def execute_code_blocks(
self, code_blocks: List[CodeBlock], cancellation_token: CancellationTokenView on GitHub (pinned to 027ecf0a37)
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.
Example fix
# before executor = LocalCommandLineCodeExecutor(timeout=60) # first execute_code_blocks triggers pip install of torch -> ValueError: Pip install timed out # after executor = LocalCommandLineCodeExecutor(timeout=600)
Defensive patterns
Strategy: validation
Validate before calling
HEAVY = {"torch", "tensorflow", "transformers", "numpy", "pandas"}
def needs_generous_timeout(imports: set[str]) -> bool:
return bool(imports & HEAVY) Try / catch
try:
await executor.execute_code_blocks(blocks, token)
except ValueError as e:
if "Pip install timed out" in str(e):
executor = LocalCommandLineCodeExecutor(timeout=600, functions=functions)
await executor.execute_code_blocks(blocks, CancellationToken())
else:
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Pip install failed. {stdout.decode()}, {stderr.decode()}
- Pip install was cancelled
- Functions failed to load: {exec_result.output}
- Invalid message type
- No such element.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/2521a8c18044bece.
Report an issue: GitHub.