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.hpp:57:11: fatal error: pyconfig.h: No such file or directory
# include <pyconfig.h>
^~~~~~~~~~~~
I tried to look up online, e.g., https://github.com/boostorg/build/issues/289
Follow their suggestion I check my "project-config.jam" And I found
# Python configuration
import python ;
if ! [ python.configured ]
{
using python : 3.7 : /home/lowlimb/anaconda3 :/home/lowlimb/anaconda3/include/python3.7m;
}
Which is correct, thus I really don't know how to fix this issue. Can anyone provide me some advice?
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.
pyconfig.h is installed with sudo apt install python-dev
To build with a specific python version, you can do
./bootstrap.sh --with-python=<path to python>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With