Skip to content Skip to sidebar Skip to footer

Cannot Build Boost Python Library (fatal Error: Pyconfig.h: No Such File Or Directory)

I am trying to build the boost python library on my ubuntu. However, when I execute ./b2 --with-python It always returns me errors related to ./boost/python/detail/wrap_python.hp

Solution 1:

pyconfig.h is installed with sudo apt install python-dev

To build with a specific python version, you can do

./bootstrap.sh --with-python=<pathtopython>

e.g.

./bootstrap.sh --with-python=python3

to use your system's python3 or

./bootstrap.sh --with-python=$VIRTUAL_ENV/bin/python

to use the python from your virtual environment.

Solution 2:

In addition to installing the python dev libs as suggested by the other answers, you can specify the python path directly:

CPLUS_INCLUDE_PATH=/usr/include/python3.7 make

Or in your case something like:

CPLUS_INCLUDE_PATH=/home/lowlimb/anaconda3/include/python3.7 ./b2

This worked for me when compiling a projects using Boost Python where I got the same error.

Solution 3:

In order to build Boost-Python or more generally, use Python from C/C++, you need the Python development files:

$ sudo apt install python3.7-dev

Post a Comment for "Cannot Build Boost Python Library (fatal Error: Pyconfig.h: No Such File Or Directory)"