Docker can't find pip3, even though its installed

Docker can’t find pip3, even though its installed

 % which pip3                   
/usr/local/bin/pip3

% docker build --target test -t todobackend-test .
Sending build context to Docker daemon  372.7kB
...
Step 4/12 : RUN apk add --no-cache gcc python3 python3-dev libffi-dev musl-dev linux-headers mariadb-dev
 ---> Using cache
 ---> 7e64185b97f9
Step 5/12 : RUN pip3 install wheel
 ---> Running in 7aa68a2249b4
/bin/sh: pip3: not found
The command '/bin/sh -c pip3 install wheel' returned a non-zero code: 127

What is the easiest way to solve this?

Uhm, you did use which pip3 on your host, didn’t you? This is completly unrelated to what is in inside the image.

Add py3-pip to your apk add command.

1 Like

That worked, thank you.

I’m following an example from a book, which is obviously outdated.

Don’t worry, It just took me a couple of seconds to google for “apk add pip3” :wink:

You might want to take a llok at the excellent Introduction to Docker and Containers self-paced tutorial.

1 Like