Dockerfile RUN pip install exit code 1 in CI
pip exited non-zero inside a RUN step, so the whole build step fails with exit code 1. The real reason is in the pip output above the summary line: usually no network to PyPI, or a source build that needs a compiler the image lacks.
What this error means
A RUN pip install step ends with "process \"/bin/sh -c pip install -r requirements.txt\" did not complete successfully: exit code: 1" after pip prints a network or build error.
ERROR: failed to solve: process "/bin/sh -c pip install -r requirements.txt"
did not complete successfully: exit code: 1Common causes
No egress or proxy for PyPI inside the build
The build network cannot reach PyPI, so pip fails with a name-resolution or timeout error and exits 1.
A source build with no compiler or headers
A package with no wheel for the platform compiles from source and needs build tools or -dev headers a slim image does not include.
How to fix it
Add the build dependencies pip needs
Install a compiler and headers before pip when a source build is unavoidable.
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential python3-dev \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir -r requirements.txtConfigure the index or prefer wheels
- Point pip at an internal mirror with
PIP_INDEX_URLwhen egress is restricted. - Force binary wheels so no compiler is needed where possible.
- Ensure the build has DNS and egress to the index.
RUN pip install --only-binary=:all: -r requirements.txtHow to prevent it
- Give the build network access to the package index it needs.
- Install
-devpackages and a compiler for unavoidable source builds. - Prefer wheels so the build never invokes a compiler.