module compiled with swig not found by python

Posted by openbas on Stack Overflow See other posts from Stack Overflow or by openbas
Published on 2010-05-01T20:24:53Z Indexed on 2010/05/01 20:27 UTC
Read the original article Hit count: 323

Filed under:
|
|
|

Hello,

I've a problem with SWIG and python. I've a c-class that compiles correctly, but the python script says it can't find the module.

I compile with:

swig -c++ -python codes/codes.i
g++ -c -Wall -O4 -fPIC -pedantic codes/*.cc
g++ -I/usr/include/python2.6 -shared codes/codes_wrap.cxx *.o -o _codes.so

This gives me a _codes.so file, as I would expect, but then I have this python file:

import sys
import codes

(rest of the code omitted)

It gives me:

 Traceback (most recent call last):
   File "script.py", line 3, in <module>
    import codes
ImportError: No module named codes

According to http://www.swig.org/Doc1.3/Introduction.html#Introduction_nn8 this is all I should have to do... The files are in the same directory, so the path should not be a problem ?

© Stack Overflow or respective owner

Related posts about python

Related posts about swig