Using VSCode (which I'm quite new to) on Ubuntu 20.04, I wish to build a C-extension (actually C++ extension) to Python.
I'm trying to build the following MWE:
#include <numpy/arrayobject.h>
int main() {return 0;}
However the build fails on #include <numpy/arrayobject.h> with the error
/usr/include/numpy/ndarrayobject.h:11:10: fatal error: Python.h: No such file or directory
I do have python3.9-dev installed, and my c_cpp_properties.json is supposed to contain the relevant path to include:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/python3.9",
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}
This question was supposedly answered plenty of times in the past, and yet nothing works for me from any answer I found.
Thank you for your help.
c_cpp_properties.jsonhas nothing to do with the compiler. The file you need to edit to affect the compiler istasks.json./usr/include/python3.9by default?tasks.jsonfile contains arguments passed to the compiler g++. Judging by your question above, you need to add the argument"-I/usr/include/python3.9""args"list, I now get another errors: 1./usr/include/python3.9/object.h:430: undefined reference to `_Py_Dealloc'. 2./usr/include/numpy/__multiarray_api.h:1466: undefined reference to `PyImport_ImportModule'