import extension module

Michael P. Reilly arcege at shore.net
Tue May 18 13:12:57 EDT 1999


Xiaohong Yuan <xhyuan at oe.fau.edu> wrote:

: Could anybody help me with the following problem?

: I am working on QNX, my Python version is 1.5. I am changing some c file
: to Python extensions. The name of the c file is smmodule.c. It is compiled
: into smmodule.so. It is under my home directory, e.g., /home/xhyuan/mytest.

: I then do the following operation:

: python
:>>import sm

: It reports:

: Traceback (innermost last):
:   File "<stdin>", line 1, in ?  ImportError: No module named sm

: I also added explicitly my directory to sys.path, but the same error is
: reported. I don't think it is the path problem, since when I import a
: "*.py" file under the same directory, it doesn't report any error. Is it
: something related to the QNX system?

I can't say for certain, but it sounds like it might be a naming
mismatch inside the C code.

C extension modules have a key function that must exist: init<module>
If the init<module> does not exist, then the module initializer cannot
be called and the module failed the import procedure.  Check to make
sure that you called the function "initsm" and not "init_sm" or
"initsmmodule".

  -Arcege





More information about the Python-list mailing list