“The headers or library files could not be found for jpeg” installing Pillow on Alpine Linux

后端 未结 10 1756
闹比i
闹比i 2021-02-01 12:33

I\'m trying to run Python\'s Scrapy in a Docker container based on python:alpine. It was working before, but now I\'d like to use Scrapy\'s Image Pipeline which requires me to i

10条回答
  •  别跟我提以往
    2021-02-01 13:01

    In short, this helps:

    RUN apt-get update -qq && apt-get install -y build-essential libsqlite3-dev \
      libpng-dev libjpeg-dev
    

    Detailed:

    I have the same error with python:3.8-slim-buster image. Solution presented by @pierangelo-orizio worked for me, but I just cleaned it to a minimal required packages list. So here are my Dockerfile:

    FROM python:3.8-slim-buster
    
    RUN apt-get update -qq && apt-get install -y build-essential libsqlite3-dev \
        libpng-dev libjpeg-dev
    
    COPY requirements.txt .
    RUN pip install --upgrade pip
    RUN pip install -r requirements.txt
    
    EXPOSE 8000
    VOLUME /usr/src/app
    WORKDIR /usr/src/app
    CMD python manage.py runserver 0.0.0.0:8000
    

    And requirements.txt:

    Django>=2.1,<2.2
    wagtail>=2.4,<2.5
    django-cors-headers==2.5.3
    python-dotenv==0.10.3
    

提交回复
热议问题