无法在Python中安装Boost - 找不到pyconfig.h

时间:2017-03-16 16:13:10

标签: python-3.x boost dlib

我跟随这个tutorial关于如何使用Python进行简单的人脸识别。本教程依赖于我尝试安装的dlib库。但是,dlib库依赖于Boost库并产生此错误:

-- Found PythonLibs: /Library/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6.dylib (found suitable version "3.6.0", minimum required is "3.4")
--  *****************************************************************************************************
--  To compile Boost.Python yourself download boost from boost.org and then go into the boost root folder
--  and run these commands:
--     ./bootstrap.sh --with-libraries=python
--     ./b2
--     sudo ./b2 install

当我从Boost下载文件夹运行./bootstrap.sh --with-libraries=python时,出现以下错误:

darwin.compile.c++ bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/numeric.o
In file included from libs/python/src/numeric.cpp:6:
In file included from ./boost/python/numeric.hpp:8:
In file included from ./boost/python/detail/prefix.hpp:13:
./boost/python/detail/wrap_python.hpp:50:11: fatal error: 'pyconfig.h' file not found
# include <pyconfig.h>
          ^
1 error generated.

    "g++"  -ftemplate-depth-128 -O3 -Wall -dynamic -gdwarf-2 -fexceptions -Wno-inline -fPIC -arch x86_64  -DBOOST_ALL_NO_LIB=1 -DBOOST_PYTHON_SOURCE -DNDEBUG  -I"." -I"/Users/mikkeld/anaconda/include/python3.5" -c -o "bin.v2/libs/python/build/darwin-4.2.1/release/threading-multi/numeric.o" "libs/python/src/numeric.cpp"

我有点迷失在这里,并试图四处寻找,没有运气。谁能发现问题是什么?

4 个答案:

答案 0 :(得分:2)

感谢这个解决方案,上面的一个我通过以下方式找到了我的python包含链接: 打开您的终端并运行: python --version

将3.7替换为当前的Python版本并运行:

python3.7-config --includes --libs

链接:

/Users/<username>/.pyenv/versions/3.6.7/Python.framework/Versions/3.6/include/python3.6m

并替换了我在下面C_INCLUDE_PATH中找到的链接

编辑/etc/profile,并将其追加到文件后,您应该修改用于指定python标头的路径

C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/include/python3.6m
export C_INCLUDE_PATH
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/include/python3.6m
export CPLUS_INCLUDE_PATH
Source /etc/profile

再次编译 现在可以编译增强了!

答案 1 :(得分:0)

我编译boost时也遇到了这个问题,以下是我的解决方案。

  1. 安装python
  2. 编辑/ etc / profile,并在文件后追加,你应该修改指定你的python头的路径

    C_INCLUDE_PATH = $ C_INCLUDE_PATH:/usr/local/include/python3.6m

    导出C_INCLUDE_PATH

    CPLUS_INCLUDE_PATH = $ CPLUS_INCLUDE_PATH:/usr/local/include/python3.6m

    导出CPLUS_INCLUDE_PATH

  3. 来源/ etc / profile

  4. 再次编译

  5. 它对我有用,希望你这样。

答案 2 :(得分:0)

这是使用水蟒的人的答案。

打开您的终端并运行:
python --version

3.7替换为当前的Python版本并运行:
python3.7-config --includes --libs

  

-I / home / victor / anaconda3 / include / python3.7m -I / home / victor / anaconda3 / include / python3.7m   -lpython3.7m -lpthread -ldl -lutil -lrt -lm

现在,获取返回的第一项并将以下行添加到您的~/.bashrc上:

export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/home/victor/anaconda3/include/python3.7m"

获取新的bashrc文件
source ~/.bashrc_profile

答案 3 :(得分:0)

这是一项在Ubuntu 18.04上的anaconda的boost 1.72和python 3.7下为我工作的技术。

  • 确保您的anaconda环境处于活动状态(路径中正确的python)
  • 在增强源树中编辑文件tools/build/src/tools/python.jam
  • 寻找第547行includes ?= $(prefix)/include/python$(version) ;
  • 替换为includes ?= $(prefix)/include/python$(version)m ;
  • ./bootstrap.sh./b2 install照常