Home > Software design >  How to install package in Dockerfile by using Python -m pip install
How to install package in Dockerfile by using Python -m pip install

Time:12-15

I am installing Onnxruntime-extensions from official git repo but fail in Dockerfile:

the packages are not ready yet, so it could be installed from source. Please make sure the compiler toolkit like gcc(later than g 8.0) or clang, and the tool cmake are installed before the following command

python -m pip install git https://github.com/microsoft/onnxruntime-extensions.git

Dockerfile

  • this is not working.

RUN python -m pip install git https://github.com/microsoft/onnxruntime-extensions.git


    FROM ubuntu:20.04
    ENV TZ=continent/capital
    
    RUN apt-get update && apt-get install software-properties-common -y &&\
    add-apt-repository -y ppa:deadsnakes/ppa && \
    apt-get update && \
    apt-get install -y libopencv-dev && \
    apt-get install -y git && \
    apt-get install -yq tzdata &&\
    ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
    
    RUN apt-get install -y python3.7 python3-pip python3.7-dev libc-dev build-essential zlib1g-dev libxml2-dev libxslt1-dev antiword unrtf poppler-utils >
    flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig
    RUN apt-get install -y gunicorn
    
    #set the working directory
    WORKDIR /project
    
    #copy requriment file to docker set directory
    COPY ./requirements.txt  /project
    
    #install dependencies for onnx
    RUN apt install -y libprotobuf-dev protobuf-compiler
    
    
    
    #WORKDIR /project/build
    RUN apt-get update && apt-get -y install cmake
    
    
    #installing requirements txt file
    RUN pip install --no-cache-dir --upgrade -r requirements.txt
    
    # installing onnxrunttime-extensions   --------Problem is here-------
    RUN python -m  pip install git https://github.com/microsoft/onnxruntime-extensions.git
    
    RUN pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_lg-3.4.0/en_core_web_lg-3.4.0-py3-none-any.whl
    
    # copy the scripts and all to the set directory
    COPY . /project
    
    # start the server
    CMD ["gunicorn"  , "-b", "0.0.0.0:8000", "wsgi:app", "--workers=33", "--timeout=28800"]

Error


    => ERROR [docker-project 10/12] RUN python -m  pip install git https://github.com/microsoft/onnxruntime-extensions.git  
    
    > [docker-project 10/12] RUN python -m  pip install git https://github.com/microsoft/onnxruntime-extensions.git:
    #0 0.284 /bin/sh: 1: python: not found
    ------
    failed to solve: executor failed running [/bin/sh -c python -m  pip install git https://github.com/microsoft/onnxruntime-extensions.git]: exit code: 127

Any help would be appreciated please have a look and please dont ignore .

CodePudding user response:

Perhaps use python3 instead of python.

CodePudding user response:

Python is not installed (checked both python and python3). Install it with apt or apt-get
apt-get update && apt-get install -y python3.8 python3-pip

  • Related