Hello,
What version of kamailio are you using ?

It is not enough just to add 'loadmodule "app_python.so"'. This module have to be configured properly.
For example:
modparam("app_python", "script_name", "/path/to/python/file.py"
modparam("app_python", "mod_init_function", "mod_init")
modparam("app_python", "child_init_method", "child_init")



2013/6/13 phil lemelin <phil.lemelin@gmail.com>
Good morning,

I'm trying to use the app_python module with Kamailio but i'm unable to even reach a point where it loads my python module.

My host:

CentOS release 6.3 (Final)
2.6.32-042stab076.7
x86_64

The installed packages:

[root@host ~]# rpm -qa | grep kamai
kamailio-4.0.1-1.1.x86_64
kamailio-mysql-4.0.1-1.1.x86_64
kamailio-python-4.0.1-1.1.x86_64


Configuration modification:

#!define WITH_MYSQL
loadmodule "app_python.so"


The python module:

[root@phone ~]# cat /usr/local/etc/sip-router/handler.py

class Handler(object):
    def child_init(self, y):
        return 0

def mod_init():
    return Handler()




When I start Kamailio, it fails like this:

[root@host ~]# kamailio -D 1 -E -e
loading modules under /usr/local/lib/kamailio/modules_k/:/usr/lib64/kamailio/modules/
 0(729) NOTICE: <core> [sr_module.c:627]: /usr/lib64/kamailio/modules/app_python.so: exports dlflags interface is deprecated and it will not be supported in newer versions; consider using mod_register() instead
Listening on
             udp: 127.0.0.1:5060
             udp: 10.3.105.49:5060
             tcp: 127.0.0.1:5060
             tcp: 10.3.105.49:5060
Aliases:
             tcp: phone:5060
             tcp: phone.dev.net2.irg:5060
             tcp: localhost4:5060
             tcp: localhost4.localdomain4:5060
             tcp: localhost:5060
             tcp: localhost.localdomain:5060
             udp: phone:5060
             udp: phone.dev.net2.irg:5060
             udp: localhost4:5060
             udp: localhost4.localdomain4:5060
             udp: localhost:5060
             udp: localhost.localdomain:5060

WARNING: no fork mode and more than one listen address found (will use only the first one)
 0(729) INFO: <core> [tcp_main.c:4846]: init_tcp: using epoll_lt as the io watch method (auto detected)
 0(729) INFO: rr [../outbound/api.h:49]: Failed to import bind_ob
 0(729) INFO: rr [rr_mod.c:159]: outbound module not available
 0(729) INFO: usrloc [hslot.c:53]: locks array size 512
 0(729) ERROR: <core> [sr_module.c:939]: init_mod(): Error while initializing module db_mysql (/usr/lib64/kamailio/modules/db_mysql.so)
 0(729) ERROR: app_python [python_support.c:132]: mod_init: Unhandled exception in the Python code:
AttributeError: init_modules() has failed
 0(729) ERROR: <core> [sr_module.c:939]: init_mod(): Error while initializing module app_python (/usr/lib64/kamailio/modules/app_python.so)
ERROR: error while initializing modules




And with -d -d -d :

*snip*
0(751) DEBUG: <core> [sr_module.c:674]: find_export_record: found <t_release> in module tm [/usr/lib64/kamailio/modules/tm.so]
 0(751) DEBUG: <core> [sr_module.c:935]: DEBUG: init_mod: app_python
 0(751) DEBUG: <core> [sr_module.c:935]: DEBUG: init_mod: db_mysql
 0(751) ERROR: <core> [sr_module.c:939]: init_mod(): Error while initializing module db_mysql (/usr/lib64/kamailio/modules/db_mysql.so)
 0(751) ERROR: app_python [python_support.c:132]: mod_init: Unhandled exception in the Python code:
AttributeError: init_modules() has failed
 0(751) ERROR: <core> [sr_module.c:939]: init_mod(): Error while initializing module app_python (/usr/lib64/kamailio/modules/app_python.so)
ERROR: error while initializing modules
 0(751) DEBUG: tm [t_funcs.c:118]: DEBUG: tm_shutdown : start
 0(751) DEBUG: tm [t_funcs.c:121]: DEBUG: tm_shutdown : emptying hash table
 0(751) DEBUG: tm [t_funcs.c:123]: DEBUG: tm_shutdown : removing semaphores
 0(751) DEBUG: tm [t_funcs.c:125]: DEBUG: tm_shutdown : destroying tmcb lists
 0(751) DEBUG: tm [t_funcs.c:128]: DEBUG: tm_shutdown : done
 0(751) DEBUG: <core> [mem/shm_mem.c:242]: shm_mem_destroy
 0(751) DEBUG: <core> [mem/shm_mem.c:245]: destroying the shared memory lock


I've been trying all the configuration permutation I could think off.
Am I missing a package or something in the configuration ?

Regards,

--
Phil.

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users