Code: Alles auswählen
#include <Python.h>
#include <stdio.h>
main(int argc, char *argv[])
{
Py_Initialize();
char *path, *newpath;
path=Py_GetPath();
newpath=(char*)malloc((strlen(path)+44)*sizeof(char));
strcpy(newpath, path);
strcat(newpath, ":.:/usr/lib/python2.5/site-packages/Numeric"); // ":." for unix, or ";." for windows
PySys_SetPath(newpath);
free(newpath);
PyObject* modul2 = PyImport_ImportModule("numpy");
if(modul2 == 0)
{
printf("-----\n");
}
/*
PyObject* modul = PyImport_ImportModule("coeff");
if(modul == 0)
{
printf("Could not import coefficient module\n");
Py_Finalize();
return 0;
}
PyObject* funk = PyObject_GetAttrString(modul, "calcCoeff8x8");
PyObject* ret = PyObject_CallObject(funk,0);
int i;
for(i = 0; i < 1; ++i)
printf("%f\n", PyFloat_AsDouble(PyTuple_GetItem(ret,i)));
Py_DECREF(ret);
Py_DECREF(funk);
Py_DECREF(modul);
*/
Py_DECREF(modul2);
Py_Finalize();
return 0;
}
Dies ist ein Testprogramm, wie ihr seht, ist eine Menge auskommentiert. Mein Modul coeff.py ist im gleichen Ordner wie die binary und beinhaltet derzeit nur:
Code: Alles auswählen
try:
from numpy import *
except:
print "no numpy available"
Hat wer eine Idee, woran das liegen könnte?
Vielen Dank für eure Hilfe!