pyconfig.h no such file

环境

  • ubuntu 16
  • python3.5

问题描述

python虚拟环境中用pip安装dlib库时出现错误如下,显示找不到文件

fatal error: x86_64-linux-gnu/python3.5m/pyconfig.h: No such file or directory
 #  include 
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

问题解决

Try 1

采用编译方式安装dlib如下,错误依旧

git clone https://github.com/davisking/dlib.git
cd dlib
mkdir build
cd build
cmake .. -DDLIB_USE_CUDA=0 -DUSE_AVX_INSTRUCTIONS=1
cmake --build .
cd ..
python3 setup.py install --no DLIB_USE_CUDA

Try 2

尝试安装库python3.5-dev,反馈显示已经安装过,错误依旧。

sudo apt-get install python3.5-dev

Try 3

查找名为pyconfig.h的文件

sudo find / -name pyconfig.h

发现系统中存在错误提示中的文件,可能是路径的问题。

/usr/include/python2.7/pyconfig.h
/usr/include/python3.5m/pyconfig.h
/usr/include/x86_64-linux-gnu/python2.7/pyconfig.h
/usr/include/x86_64-linux-gnu/python3.5m/pyconfig.h

Try 4

查看当前环境中python引用文件的地址

python3.5-config --includes

二者不一致,前者是搜索路径,者是文件目前所在路径

-I/usr/include/python3.5m -I/usr/include/x86_64-linux-gnu/python3.5m

复制文件到搜索路径

sudo cp /usr/include/x86_64-linux-gnu/python3.5m/pyconfig.h /usr/include/python3.5m/

再次查看

python3.5-config --includes
-I/usr/include/python3.5m -I/usr/include/python3.5m

再次安装,通过。

参考

https://cyaninfinite.com/installing-opencv-in-ubuntu-for-python-3/

你可能感兴趣的:(bug,python)