python-crfsuite icon indicating copy to clipboard operation
python-crfsuite copied to clipboard

python-crfsuite fails install due gcc error Python.h: No such file or directory

Open CaseGuide opened this issue 2 years ago • 0 comments

python-crfsuite >= 0.7 is a dep of a package I use on Amazon Linux AM2 w/python 3.6 made from a docker container.

dockerfile: (should allow you to reproduce)

FROM public.ecr.aws/lambda/python:3.6

RUN yum install gcc-c++ -y

RUN python3.6 -m pip install -r requirements.txt -t .

when it gets to pip installing python-crfsuite...

    Running setup.py install for python-crfsuite: finished with status 'error'
    Complete output from command /var/lang/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-vnnqc5gi/python-crfsuite/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec
(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-4dcb1ghd/install-record.txt --single-version-externally-managed --compile --home=/tmp/pip-target-zbog9b99:

...the command ends with the following error:

    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/opt/amazon/include -I/opt/amazon/include -fPIC -Icrfsuite/include/ -Icrfsuite/lib/cqdb/include -Iliblbfgs/include -Ipycrfsuite -I/var/lang/include/python3.6m -c pyc
rfsuite/_pycrfsuite.cpp -o build/temp.linux-x86_64-3.6/pycrfsuite/_pycrfsuite.o
    pycrfsuite/_pycrfsuite.cpp:6:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

Attempting to use an earlier python-crfsuite version to see if there's a workaround.

EDIT: Pinning requirement to python-crfsuite==0.9.7 resolved the issue. I also removed RUN yum install gcc-c++ -y from dockerfile.

CaseGuide avatar Apr 21 '22 14:04 CaseGuide