C ->Python Import Wrapper Problems -


I defined the name of my wrapper object in my C file blargUtils.c (I defined methods and many Is in Blargmethods for this) ...

  zero initBlarg () {Py_InitModule ("Blarg", Blargmethods); }   

I compiled it like this ...

  blarglib: blargUtils.c gcc -i / usr / include / python2.6 -fPIC - C BlargUtils.c -Wall gcc -shared blargUtils.o -o blargUtils.so clean: rm * .so   

However, when I try to import wrapper in my Python script. ..

  import blog   

It says that it says: "Import irraw: no module blog" I have lost a bit here and I It does not understand why they are exact spellings Maybe it's a logic error?

Tell me if more code is needed.

First of all, by observing the comments, I came to know that it was not okay to change its name. (1) Python .so file can not be found, (2) .so file is not useful (i.e. is not correctly compiled or all the necessary symbols are not found), or (3) a .p / .pyc / The .pyo file is in the directory that already has that name. If you have already defined Blarg.py, then Python will see this file first. It goes the same way if you have a directory called Blogs in your search path. Instead of hitting your head against the wall, try it:

1) Do not forget to hit something to change the name of (ie _Blarg)

  zero initBlarg () {Py_InitModule ("_ blarg", BloggerMaths); }   

2) Compile it with the same name

  GCC-I / USR / includes / Python 2- -PPIC-C blog youths call BlargUtils.o -Wl, -Sonami -Wl, _Blarg.so -o _Blarg.so   

shared by GCC 3) Create a python wrapper (i.e. Blarg.py)

4) Now just use it as normal

  Import Blanc Blarg.blargFunc1 (1, 2, 3)  < / Pre> 

Obviously this is a bit of redundancy, but it should help you decide where the problem is, hopefully it helps.

Comments