Python or pip command not found

The `python` or `pip` command is not available in the CI environment's PATH.

python-command-not-found medium confidence build python

Matched signals

  • python: command not found
  • python3: command not found
  • pip: command not found
  • pip3: command not found
  • bash: python: command not found
  • bash: pip: command not found
  • /usr/bin/env: 'python': No such file or directory
  • /usr/bin/env: 'python3': No such file or directory

Python or pip command not found

What this failure means

The python or pip command is not available in the CI environment’s PATH.

Symptoms

Faultline looks for one or more of these log fragments:

python: command not found
python3: command not found
pip: command not found
pip3: command not found
bash: python: command not found
bash: pip: command not found
/usr/bin/env: 'python': No such file or directory
/usr/bin/env: 'python3': No such file or directory

Diagnosis

The CI job tried to run python, python3, pip, or pip3 but the command was not found. This usually happens when:

  • The base image does not include Python (e.g., node:alpine, debian:slim without python3).
  • Python is installed but not in the default PATH.
  • The wrong Python version is referenced (e.g., python vs python3).
  • A virtual environment is activated but the interpreter is missing.

This is distinct from a generic missing executable because Python is a fundamental runtime for many build and test workflows.

Fix steps

  1. Install Python in the CI environment:

    Ubuntu/Debian:

    apt-get update && apt-get install -y python3 python3-pip
    

    Alpine:

    apk add --no-cache python3 py3-pip
    

    CentOS/RHEL:

    yum install -y python3 python3-pip
    
  2. Check the available Python executable and adjust the command:

    which python3
    python3 --version
    
  3. Use python3 instead of python if the base image only provides python3.

  4. In GitHub Actions, use the actions/setup-python action to ensure a specific Python version:

    - uses: actions/setup-python@v5
      with:
        python-version: '3.12'
    
  5. If using a Docker image, switch to an image that includes Python, such as python:3.12-slim or node:20 (includes Python for node-gyp).

  6. For pip, ensure it is installed with Python or install it separately:

    python3 -m ensurepip --upgrade
    

Validation

  • python3 --version prints a version without “command not found”.
  • pip3 --version or python3 -m pip --version shows pip is available.
  • Re‑run the failing step and confirm Python/pip commands succeed.

Why it matters

Python is required for many dependency installation tools (pip, poetry), native module compilation (node-gyp), and test runners (pytest). Missing Python blocks these essential build steps.

Prevention

  • Use base images that include Python by default.
  • Standardize on python3 and pip3 in scripts to avoid ambiguity.
  • Add a pre‑step that checks for Python before running Python‑dependent commands.

Try it locally

python3 --version
which python3
python3 --version

How Faultline detects it

Use faultline explain python-command-not-found to see the full playbook.

faultline analyze build.log
faultline explain python-command-not-found

Generated from playbooks/bundled/log/build/python-command-not-found.yaml. Do not edit directly.

Try it on your own failed log

$ faultline analyze failed.log
Want this across every CI run? Faultline Teams tracks recurring failures across all your repos and surfaces patterns in a shared dashboard.