4

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 2

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much @rocksportrocker. Its worked for me
1

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.

1 Comment

For alpine based image apk add linux-headers should do the job

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.