Problem with embedding Python

Jody Winston josephwinston at mac.com
Thu Mar 30 16:39:59 CEST 2000


Alain <alain at antinea.org> writes:

> 	Hi,
> 
> 	I need to call Python from within a C program. It works well till now
> but I've to work with NumPy and I've a problem with the 'import'
> function :
> 
> [alain at kali embed1]$ cat test2.py
> from Numeric import *
> print "OK"
> [alain at kali embed1]$ python test2.py
> OK
> 
> ***** That's good
> 
> [alain at kali embed1]$ cat demo.c
> #include "Python.h"
> int main(int argc, char* argv[]) {
>         Py_SetProgramName(argv[0]);
>         Py_Initialize();
>         PyRun_SimpleString("from Numeric import *\n");
>         PyRun_SimpleString("print \"OK\"\n");
>         Py_Exit(0);
> }
> 
> [alain at kali embed1]$ ./demo
> Traceback (innermost last):
>   File "<string>", line 1, in ?
>   File "/usr/local/lib/python1.5/site-packages/Numeric/Numeric.py", line
> 6, in ?
>     import multiarray
> ImportError:
> /usr/local/lib/python1.5/site-packages/Numeric/multiarray.so: undefined
> symbol: _Py_NoneStruct
> OK
> 
> ***** That's wrong
> 
> 	Can anybody help me ?
> 
> 	Best regards, ALain

The problem is with dynamic linking.  Insure that your program has the 
correct compiler flags to support dynamic linking and insure that
/usr/local/lib/python1.5/site-packages/Numeric/multiarray.so is on the 
path that the dynamic linker uses to find libraries.

-- 
Jody Winston



More information about the Python-list mailing list