Bug: 'Failed with non-blocking status code: /bin/sh: python: command not found'
Summary
Claude Code fails with the following error when attempting to run Python-related tasks:
Failed with non-blocking status code: /bin/sh: python: command not found
Environment
- OS: macOS (likely macOS 12.3+ where Python 2 was removed from the system)
- Shell:
/bin/sh(orzsh/bash) - Python: Only
python3is available;python(Python 2 alias) does not exist
Steps to Reproduce
- Open Claude Code on macOS with no Python 2 installed (default on modern macOS)
- Ask Claude Code to run any Python script or task that invokes
python - Observe the non-blocking error:
/bin/sh: python: command not found
Expected Behavior
Claude Code should detect the available Python binary (python3) and use it, or provide a graceful, actionable error message indicating that python is not found and suggesting the user create a symlink or alias (python -> python3).
Actual Behavior
Claude Code silently fails with a non-blocking status code and the shell error /bin/sh: python: command not found. The failure is non-fatal to the agent loop but the intended task does not execute.
Root Cause (Suspected)
On macOS 12.3+, Apple removed the bundled Python 2 interpreter. The python command no longer exists by default — only python3. Claude Code appears to be invoking python directly without falling back to python3.
Workaround
Users can manually create a symlink or alias:
# Option 1: symlink via Homebrew python
ln -s /usr/local/bin/python3 /usr/local/bin/python
# Option 2: add alias in shell profile (~/.zshrc or ~/.bashrc)
alias python=python3
Suggested Fix
- Detect the Python binary at startup or task execution time: try
python, fall back topython3 - Or configure Claude Code to prefer
python3by default on macOS - Surface a clear, actionable error message when neither is found
Additional Context
This is a common issue for macOS users and affects many dev tools that assume python exists. Providing a first-class fix or user-facing guidance would significantly improve the macOS developer experience.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗