Python.h: No such file or directory

sudo apt-get install pythonX.X-dev

For example for 3.8

sudo apt-get install python3.8-dev

Thank you Cristianjs19 for the comment.

Original Answer:

sudo apt-get install python2.7-dev

worked for me on a "Python.h: No such file or directory" issue


In your CMakeLists.txt, try adding the following:

find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
target_link_libraries(<your exe or lib> ${PYTHON_LIBRARIES})

For details of the commands, run:

cmake --help-module FindPythonLibs
cmake --help-command find_package
cmake --help-command include_directories
cmake --help-command target_link_libraries