Torizon: Installing and using pip3 (Flask)

Hi team,

I’ve been trying to build a container that use python3 and pip but I’m having issues trying to install requirements.

Python seems to be working by itself but when trying to use this for our module with FROM torizon/arm64v8-debian-base python3-pip is not found, but it seems that it can be installed.

pip works if I tried to use a python image (for example FROM python:3.7-alpine as base). I’ve also tried with RUN pip install -U pip, RUN python3-pip, RUN pip3 or RUN pip but also fail.


FROM torizon/arm64v8-debian-base

RUN apt-get update 

RUN apt-get install -y --no-install-recommends \
    python3 \
    python3-pip \
    python3-setuptools \
    && rm -rf /var/lib/apt/lists/*

COPY . /FATorizonDemo 
WORKDIR /FATorizonDemo

RUN cat requirements.txt

RUN pip install -r requirements.txt

CMD ["python3", ""]


docker build -t alvarotx/fatorizondemo .
Sending build context to Docker daemon  157.6MB
Step 1/8 : FROM torizon/arm64v8-debian-base
# Executing 1 build trigger
 ---> Using cache
 ---> b2ce468568e7
Step 2/8 : RUN apt-get update
 ---> Using cache
 ---> cc92bf81c4c4
Step 3/8 : RUN apt-get install -y --no-install-recommends     python3     python3-pip     python3-setuptools     && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> e2f674221fe7
Step 4/8 : COPY . /FATorizonDemo
 ---> 5b2c34c1e2f8
Step 5/8 : WORKDIR /FATorizonDemo
 ---> Running in 2d0b9d460e1b
Removing intermediate container 2d0b9d460e1b
 ---> f1075e137eb6
Step 6/8 : RUN cat requirements.txt
 ---> Running in 66174c3f4fef
Flask==1.1.2Removing intermediate container 66174c3f4fef
 ---> d282160dd898
Step 7/8 : RUN pip install -r requirements.txt
 ---> Running in e05f6ac82248
/bin/sh: 1: pip: not found
The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 127

Any idea?

Thanks and kind regards,

You should use pip3 instead of pip that is used for the old (now no longer supported) python2 version.
In general, it is a good idea to explicitly reference python3 and pip3 in your scripts.
And we have a Visual Studio Code extension that can create that container for your, solving all those issues and also allowing you to deploy and debug the application on the target:
For packages that include native code or build native code on the target it may be a good idea to add them as debian packages and not via pip (this does not apply to Flask).

Thanks Valter! I could easily do this through the VSCode plugin, by adding Flask==1.1.2 into requirements.txt. As for Flask specific, as discussed, adding the port through the “Torizon Devices” tag → CONFIGURATIONS → Ports → 5005/tcp : 5005, worked perfectly.

Also, by checking the dockerfile generated by the plugin (inside appconfig_0, Dockerfile.debug) I could manage to build through my own Dockerfile:

FROM torizon/arm64v8-debian-base:buster

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
    python3 \
    python3-pip \
    python3-setuptools \
    && rm -rf /var/lib/apt/lists/*

RUN pip3 install --upgrade pip

COPY . /FATorizonDemo 
WORKDIR /FATorizonDemo

RUN pip3 install -r requirements.txt

CMD ["python3", ""]