Python.h: No such file or directory on Amazon Linux Lambda Container

  amazon-linux, aws-lambda, docker, pip, python-c-api

I am trying to build this public.ecr.aws/lambda/python:3.6 based Dockerfile with a requirements.txt file that contains some libraries that need gcc/g++ to build. I’m getting an error of a missing Python.h file despite the fact that I installed the python development package and /usr/include/python3.6m/Python.h exists in the file system.

Dockerfile

FROM public.ecr.aws/lambda/python:3.6
COPY requirements.txt /
RUN yum install -y gcc gcc-c++ python36-devel.x86_64
RUN pip install --upgrade pip && 
    pip install -r /requirements.txt
COPY app.py ./
CMD ["app.handler"]

requirements.txt

cyquant==1.0.0a10

When I build this with

docker build -t redux .

I get the following error

cyquant/dimensions.cpp:4:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                    ^
compilation terminated.
error: command 'gcc' failed with exit status 1

Notice, however, that my Dockerfile yum installs the development package. I have also tried the yum package python36-devel.i686 with no change.

What am I doing wrong?

Source: Docker Questions

LEAVE A COMMENT