gcc' failed with exit status - Python docker integration error

Viewed 11398

I'm new to Python and trying to build a python application with Docker setup. When I try to build my docker (i.e. docker build -t python-barcode), I get the following error

error: command 'gcc' failed with exit status 1 (ss: https://www.screencast.com/t/Do1Bjkbo)

I tried to install gcc. I couldn't find any packages. Your help is much appreciated. Thanks in advance.

Dockerfile

 FROM python:3.6
    # Create app directory
    WORKDIR /app

    # Install app dependencies
    COPY src/requirements.txt ./

    RUN pip install -r requirements.txt
    RUN pip install zbar
    RUN pip install pyzbar
    # Bundle app source
    COPY src /app

    EXPOSE 8080
    CMD [ "python", "ocrApi.py" ]

requirements.txt file

flask
Pillow
pytesseract
opencv-python
requests

ocrApi.py file

from flask import Flask,jsonify,request
from PIL import Image
from pyzbar.pyzbar import decode
import pytesseract
#import pyzbar.pyzbar as pyzbar
import cv2
import io,os
import requests
import urllib.request
import random
pytesseract.pytesseract.tesseract_cmd = r'C:\Users\chethan\Tesseract-OCR\tesseract'
....
2 Answers

I looked at your output. Not gcc is missing but the header files for zbar.

So add extra

RUN apt-get -y update && apt-get install -y libzbar-dev

to the Dockerfile before running pip.

So the same error occurred to me also. I was using python:3.6-alpine and I upgraded it to python:3.7-alpine.Now, It is working fine without adding libzbar-dev.

Related