Search code examples
pythoncgccincludeinclude-path

gcc : Unable to find Python.h, When its there in /usr/includes/python2.7?


My C code:

#include<stdio.h>
#include "Python.h"

int main()
{
    printf("Hello World");
    return 0;
}

I have python-dev installed for python2.7. Moreover, Python.h is available in /usr/include/python2.7.

gcc myfile.c # Python.h: No such file or directory

I even tried : gcc -L/usr/include/python2.7/ myfile.c # Python.h: No such file or directory

I tried building a python c module ujson with pip that uses Python.h, it was able to compile.

What am I missing / doing wrong ?


Solution

  • It should be -I, not -L:

    gcc -I/usr/include/python2.7 myfile.c