VSCode: "fatal error: Python.h: No such file or directory" even with python-dev installed

90 views Asked by At

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.

0

There are 0 answers