pytorch - 💡(How to fix) Fix macos-py3-arm64-mps test job fails in setup-python: ensurepip returns non-zero [1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#181598Fetched 2026-04-28 06:24:33
View on GitHub
Comments
1
Participants
1
Timeline
41
Reactions
0
Author
Participants
Timeline (top)
subscribed ×22mentioned ×11labeled ×5added_to_project_v2 ×1

The macos-py3-arm64-mps / test (test_mps, 1, 1, macos-m2-26) job is failing during the pytorch/test-infra setup-python action when bootstrapping pip into a freshly created venv.

Error Message

Job step freshly brew installs [email protected] (resolves to [email protected] 3.12.13_1 from the arm64_tahoe bottle) at /opt/homebrew/bin/python3.12, then calls python3.12 -m venv which fails during the ensurepip step:

Using python at /opt/homebrew/bin/python3.12 to create venv /Users/ec2-user/runner/_work/_temp/venv-3.12-1777296482
Error: Command '['/Users/ec2-user/runner/_work/_temp/venv-3.12-1777296482/bin/python3.12', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
node:child_process:966
    throw err;
    ^

Error: Command failed: \"/opt/homebrew/bin/python3.12\" -m venv \"/Users/ec2-user/runner/_work/_temp/venv-3.12-1777296482\"
    at genericNodeError (node:internal/errors:984:15)
    ...
    at Object.<anonymous> (/Users/ec2-user/runner/_work/_actions/pytorch/test-infra/main/.github/actions/setup-python/setup.js:29:1)

The wrapper (pytorch/test-infra/.github/actions/setup-python/setup.js) calls execSync and only surfaces the non-zero exit code — the actual stderr from ensurepip is swallowed (stdout: null, stderr: null), which makes this hard to diagnose.

Root Cause

The macos-py3-arm64-mps / test (test_mps, 1, 1, macos-m2-26) job is failing during the pytorch/test-infra setup-python action when bootstrapping pip into a freshly created venv.

Code Example

Using python at /opt/homebrew/bin/python3.12 to create venv /Users/ec2-user/runner/_work/_temp/venv-3.12-1777296482
Error: Command '['/Users/ec2-user/runner/_work/_temp/venv-3.12-1777296482/bin/python3.12', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
node:child_process:966
    throw err;
    ^

Error: Command failed: \"/opt/homebrew/bin/python3.12\" -m venv \"/Users/ec2-user/runner/_work/_temp/venv-3.12-1777296482\"
    at genericNodeError (node:internal/errors:984:15)
    ...
    at Object.<anonymous> (/Users/ec2-user/runner/_work/_actions/pytorch/test-infra/main/.github/actions/setup-python/setup.js:29:1)
RAW_BUFFERClick to expand / collapse

Summary

The macos-py3-arm64-mps / test (test_mps, 1, 1, macos-m2-26) job is failing during the pytorch/test-infra setup-python action when bootstrapping pip into a freshly created venv.

Failing run

Error

Job step freshly brew installs [email protected] (resolves to [email protected] 3.12.13_1 from the arm64_tahoe bottle) at /opt/homebrew/bin/python3.12, then calls python3.12 -m venv which fails during the ensurepip step:

Using python at /opt/homebrew/bin/python3.12 to create venv /Users/ec2-user/runner/_work/_temp/venv-3.12-1777296482
Error: Command '['/Users/ec2-user/runner/_work/_temp/venv-3.12-1777296482/bin/python3.12', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
node:child_process:966
    throw err;
    ^

Error: Command failed: \"/opt/homebrew/bin/python3.12\" -m venv \"/Users/ec2-user/runner/_work/_temp/venv-3.12-1777296482\"
    at genericNodeError (node:internal/errors:984:15)
    ...
    at Object.<anonymous> (/Users/ec2-user/runner/_work/_actions/pytorch/test-infra/main/.github/actions/setup-python/setup.js:29:1)

The wrapper (pytorch/test-infra/.github/actions/setup-python/setup.js) calls execSync and only surfaces the non-zero exit code — the actual stderr from ensurepip is swallowed (stdout: null, stderr: null), which makes this hard to diagnose.

Suggestions

  1. Capture stderr in the action. The setup-python setup.js currently uses execSync without inheriting stdio (or piping/printing stderr on failure), so the underlying ensurepip error is invisible. It should print stderr/stdout when the venv creation fails so we can see why ensurepip exited non-zero.
  2. Possibly related to the just-installed [email protected] 3.12.13_1 brew bottle on arm64_tahoe — could be a broken bottle or a runner state issue (stale _temp/venv-* directory, missing wheels, broken symlink to a previously brew-installed Python). A retry with python3.12 -m venv --without-pip followed by python3.12 -m ensurepip (with output captured) on the runner would help isolate.

cc @seemethere @pytorch/pytorch-dev-infra @aditvenk @snadampal @milpuz01 @aditew01 @nikhil-arm @fadara01 @robert-hardwick @nWEIdia @malfet @huydhn

extent analysis

TL;DR

Capture stderr in the setup-python action to diagnose the underlying ensurepip error.

Guidance

  • Modify the setup.js script to capture and print stderr when the venv creation fails.
  • Retry the venv creation with python3.12 -m venv --without-pip followed by python3.12 -m ensurepip to isolate the issue.
  • Verify that the _temp/venv-* directory and other dependencies are properly cleaned up between runs.
  • Check the brew installation of [email protected] 3.12.13_1 for any issues or corruption.

Example

const { execSync } = require('child_process');

try {
  const result = execSync('/opt/homebrew/bin/python3.12 -m venv /Users/ec2-user/runner/_work/_temp/venv-3.12-1777296482', { stdio: 'inherit' });
} catch (error) {
  console.error('Error creating venv:', error);
  console.error('stderr:', error.stderr);
}

Notes

The actual error message from ensurepip is not visible due to the current implementation of the setup-python action, making it difficult to diagnose the issue. Capturing stderr will provide more information about the failure.

Recommendation

Apply workaround: Capture stderr in the setup-python action to diagnose the underlying ensurepip error, as it will provide more information about the failure and help isolate the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - 💡(How to fix) Fix macos-py3-arm64-mps test job fails in setup-python: ensurepip returns non-zero [1 comments, 1 participants]