Error : python.h : no such file or directory

Shaun Hogan shogan at iel.ie
Wed Mar 15 06:14:21 EST 2000


i have this simple c program which i want to be able to import into python
and run it form there:
the c prog is:

#include <stdio.h>

main()
{
int x,y,z;

printf("enter 2 numbers\n");
scanf("%d %d", &x,&y);
z=x*y;
printf("%d*%d=%d",x,y,z);
}

i want to be able to type in the python interpreter:
from res import *
getresult()
and then up pops my function

the code i have come up with so far is:

#include <python.h>
#include <stdio.h>
#include <stdlib.h>

PyObject * getres(PyObject * self, PyObject * args);

typedef struct

int x,y,z;

static PyMethodDef resMethods[]=
{
{"getresult", getres, METH_VARARGS},
{NULL}
} ;

void initres()
{
    (void) Py_Initmodule ("res", resMethods);
}

int getresult
{
    printf("enter 2 numbers\n");
    scanf("%d %d", &x,&y);
    z=x*y;
    printf("%d*%d=%d",x,y,z);
}

now, when i try to compile this i get the ": python.h : no such file or
directory"  error and it wont create the .o file i need to put in
Setup.local to use it as a module.

can anyone help me?

thanks
Shaun






More information about the Python-list mailing list