makecython ++导致致命错误:Python.h:尽管安装了python3-dev,但没有这样的文件或目录

时间:2017-03-27 01:34:22

标签: python ubuntu cython python-c-api python-c-extension

我的makefile:

SHELL := /bin/bash

.PHONY: all
all:
    pip install runcython
    makecython++ stitch_wrapper.pyx "" "stitch_rects.cpp ./hungarian/hungarian.cpp"

hungarian: hungarian/hungarian.so

hungarian/hungarian.so:
    cd hungarian && \
    TF_INC=$$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())') && \
    if [ `uname` == Darwin ];\
    then g++ -std=c++11 -shared hungarian.cc -o hungarian.so -fPIC -I $$TF_INC -undefined dynamic_lookup;\
    else g++ -std=c++11 -shared hungarian.cc -o hungarian.so -fPIC -I  $$TF_INC; fi

我已经安装了

-cython
-runcython
-python-dev
-python3-dev
-cffi

不幸的是我继续得到错误:

pkg-config: command not found
.cpp:4:20: fatal error: Python.h: No such file or directory
compilation terminated.
Makefile:5: recipe for target 'all' failed
make: *** [all] Error 1

1 个答案:

答案 0 :(得分:3)

如果你已经

sudo apt-get install python-dev
sudo apt-get install python3-dev
sudo apt-get install libpython3-dev
sudo apt-get install libpython3.4-dev
sudo apt-get install libpython3.5-dev

问题可能与缺少其中一个包有关:

sudo apt-get install Cython
sudo apt-get install pkgconf
sudo apt-get install libpkgconf
sudo apt-get install python-pkgconfig
sudo apt-get install python3-pkgconfig