3

I'm following along this tutorial on how to make simple face recognition using Python. The tutorial is dependent on the dlib library which I'm trying to install. However, the dlib library has a dependency on the Boost library and yields this error:

-- 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

When I run ./bootstrap.sh --with-libraries=python from the Boost download folder I get the following error:

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"

I'm a bit lost here and have tried looking around without luck. Can anyone spot what the issue is?

user3642173
  • 1,225
  • 5
  • 19
  • 42

4 Answers4

3

Thanks for this solution and one above I found my include link of python via: Open your terminal and run: python --version

Replace the 3.7 for your current Python version and run:

python3.7-config --includes --libs

link:

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

and replaced the link which I found in C_INCLUDE_PATH below

Edit /etc/profile, and append following to the file, you should modify the path for specifying your python header

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

Compile again it compiles boost now!

Ameer
  • 978
  • 4
  • 13
  • 34
omniSlash
  • 69
  • 4
1

Here is the answer for those who use Anaconda.

Open your terminal and run:
python --version

Replace the 3.7 for your current Python version and run:
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

Now, get the first item returned and add the following line on your ~/.bashrc:

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

Source your new bashrc file
source ~/.bashrc_profile

vmf91
  • 1,897
  • 19
  • 27
0

I also met this problem when I compile boost, following is my solution.

  1. Install python
  2. Edit /etc/profile, and append following to the file, you should modify the path for specifying your python header

    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

  3. Source /etc/profile

  4. Compile again

It works for me, hope you so.

zed
  • 31
  • 5
0

Here is a technique that worked for me under boost 1.72 and python 3.7 from anaconda on Ubuntu 18.04.

  • Make sure your anaconda environment is active (the correct python in path)
  • In your boost source tree edit the file tools/build/src/tools/python.jam
  • Look for line 547 includes ?= $(prefix)/include/python$(version) ;
  • Replace with includes ?= $(prefix)/include/python$(version)m ;
  • ./bootstrap.sh and ./b2 install as usual
umlum
  • 1,107
  • 6
  • 11