Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker issue: /bin/sh: pip: not found

So my dockerfile is :

FROM iron/python:2.7

WORKDIR /app
ADD . /app

RUN pip install --upgrade pip
RUN pip install -r ./requirements.txt

Recently though when I build my image with: docker build --no-cache -t <image name>:<tag>

I run into the issue of:

Step 4/6 : RUN pip install --upgrade pip
---> Running in 00c781a53487
/bin/sh: pip: not found
The command '/bin/sh -c pip install --upgrade pip' returned a non-zero code: 127

was there any changes to docker that might have caused this? Because last week this was all fine and there were no issues building the image with the same exact code.

like image 894
Raphael Baysa Avatar asked Feb 02 '18 18:02

Raphael Baysa


Video Answer


1 Answers

For Python3:

FROM ubuntu:latest
WORKDIR /app
ADD . /app
RUN set -xe \
    && apt-get update \
    && apt-get install python3-pip
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

If you install python-pip for Python2 as well, you need to use pip3 for Python3 and pip for Python2. But with this setting, pip is the same as pip3. Check with pip -V.

Thats it :-)

like image 170
vijayraj34 Avatar answered Sep 30 '22 08:09

vijayraj34