voicemail Error importing module
Forum » WikiPBX / Technical Support » voicemail Error importing module
Started by: tjaracastjaracas
On: 1238180314|%e %b %Y, %H:%M %Z|agohover
Number of posts: 7
rss icon RSS: New posts
Summary:
When a call goes into voicemail an error occurs. Importerror: No module named django.db
voicemail Error importing module
tjaracastjaracas 1238180314|%e %b %Y, %H:%M %Z|agohover

Hello, After a call is going into voicemail using the standard xml template i receive the following error in freeswitch and wikipbx log. The export python settings are in place. PLeae advice if you have an idea what might be causing this situation.

My dialplan looks like this
<action application="set" data="call_timeout=30"/>
<action application="set" data="continue_on_fail=true"/>
<action application="set" data="hangup_after_bridge=true"/>
<action application="bridge" data="sofia/arubel/7050%ipaddress"/>
<action application="set" data="vmaction=record"/>
<action application="python" data="wikipbx.ivr.voicemail"/>

the freeswitchlog shows this

2009-03-27 14:58:31 [NOTICE] mod_python.c:107 eval_some_python() Invoking py module: wikipbx.ivr.voicemail
2009-03-27 14:58:32 [ERR] mod_python.c:121 eval_some_python() Error importing module
Traceback (most recent call last):
File "/usr/src/wikipbx/ivr/voicemail.py", line 11, in ?
from wikipbx.wikipbxweb.models import *
File "/usr/src/wikipbx/wikipbxweb/models.py", line 27, in ?
from django.db import models
ImportError: No module named django.db
2009-03-27 14:58:32 [NOTICE] switch_core_state_machine.c:172 switch_core_standard_on_execute() Hangup sofia/arubel/01.411.57.091|1507#01.411.57.091|1507 [CS_EXECUTE] [NORMAL_CLEARING]

and the wikipbx does this

2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] |7050| != |^00(\d{10,15})$|
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] |7050| != |1234|
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] |7050| != |outgoing2endpoint-7444972|
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] |7050| == |^7050$| (MATCH!)
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] actions_dom: <?xml version="1.0" ?>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <actions_xml><action application="set" data="call_timeout=30"/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <action application="set" data="continue_on_fail=true"/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <action application="set" data="hangup_after_bridge=true"/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <action application="bridge" data="sofia/arubel/7050%190.75.114.10"/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <action application="set" data="vmaction=record"/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <action application="python" data="wikipbx.ivr.voicemail"/></actions_xml>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] Going to copy elt: <action application="set" data="call_timeout=30"/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] Going to copy elt: <action application="set" data="continue_on_fail=true"/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] Going to copy elt: <action application="set" data="hangup_after_bridge=true"/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] Going to copy elt: <action application="bridge" data="sofia/arubel/7050%190.75.114.10"/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] Going to copy elt: <action application="set" data="vmaction=record"/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] Going to copy elt: <action application="python" data="wikipbx.ivr.voicemail"/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <?xml version="1.0"?>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <document type="freeswitch/xml">
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <section name="dialplan" description="Various Dialplan">
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1]
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <context name='default'>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <extension name='dynamic_wikipbx_extension'>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <condition field='destination_number'>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <action application='set' data='account_id=1'/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <action application='set' data='extension_id=3'/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <action application='set' data='call_timeout=30'/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <action application='set' data='continue_on_fail=true'/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <action application='set' data='hangup_after_bridge=true'/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <action application='bridge' data='sofia/arubel/7050%190.75.114.10'/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <action application='set' data='vmaction=record'/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] <action application='python' data='wikipbx.ivr.voicemail'/>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] </condition>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] </extension>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] </context>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1]
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] </section>
2009-03-27 23:31:42+0000 [HTTPChannel,533,127.0.0.1] </document>
2009-03-27 23:31:42+0000 [-] 127.0.0.1 - - [27/Mar/2009:23:31:42 -0430] "POST /xml_dialplan/ HTTP/1.1" 200 789 "-" "freeswitch-xml/1.0"
2009-03-27 23:31:42+0000 [HTTPChannel,534,127.0.0.1] CDR Added

Reply  |  Options
Unfold voicemail Error importing module by tjaracastjaracas, 1238180314|%e %b %Y, %H:%M %Z|agohover
Re: voicemail Error importing module
stas_shtinstas_shtin 1238253050|%e %b %Y, %H:%M %Z|agohover

So, do you have Django installed as described in the installation manual?

Reply  |  Options
Unfold Re: voicemail Error importing module by stas_shtinstas_shtin, 1238253050|%e %b %Y, %H:%M %Z|agohover
Re: voicemail Error importing module
tleydentleyden 1238301386|%e %b %Y, %H:%M %Z|agohover

What seems to be happening is that the IVR executing under freeswitch cannot find the django library python code. This could happen if Django was not installed correctly (or not at all), or if Django was installed to a different version of python than the one freeswitch is using.

Please do the following:

1. Run "python" from the command line and post the python version

2. Enter

from django.db import models

on the python shell and post the output

3. Copy and paste the /usr/src/freeswitch_xxx/src/mod/languages/mod_python/Makefile file to your post

Reply  |  Options
Unfold Re: voicemail Error importing module by tleydentleyden, 1238301386|%e %b %Y, %H:%M %Z|agohover
Re: voicemail Error importing module
tjaracastjaracas 1238413526|%e %b %Y, %H:%M %Z|agohover

Pyton version Python 2.6.1 (r261:67515, Mar 23 2009, 14:19:54)
[GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

output after running from django-db import models
from django.db import models
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/site-packages/django/db/init.py", line 7, in <module>
if not settings.DATABASE_ENGINE:
File "/usr/local/lib/python2.6/site-packages/django/conf/init.py", line 28, in getattr
self._import_settings()
File "/usr/local/lib/python2.6/site-packages/django/conf/init.py", line 53, in _import_settings
raise EnvironmentError, "Environment variable %s is undefined." % ENVIRONMENT_VARIABLE
EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is undefined.

Here is the output of themakefile

  1. define these targets in your makefile if you wish
  2. local_all local_depend local_clean depend_install local_install local_distclean local_extraclean:
  1. and define these variables to impact your build

LOCAL_CFLAGS = -I/usr/include/python2.4 -I/usr/include/python2.4 -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector —param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC
LOCAL_LDFLAGS= -lpthread -ldl -lutil -lm -lpython2.4
LOCAL_OBJS=freeswitch_python.o mod_python_wrap.o
include ../../../../build/modmake.rules

LINK=$(CXXLINK)

PYMOD=freeswitch
PYTHON_SITE_DIR=/usr/lib/python2.4/site-packages

SWIGCFILE=../../../switch_swig.c
SWIGIFILE=../../../switch_swig.i

reswig: swigclean mod_python_wrap.cpp

swigclean: clean
rm -f mod_python_wrap.* freeswitch.py

mod_python_wrap.cpp: mod_python_extra.c
swig -python -c++ -I../../../../src/include -oh mod_python_wrap.h -o mod_python_wrap.cpp mod_python.i
echo "#include \"mod_python_extra.c\"" » mod_python_wrap.cpp
patch -s -p0 -i hack.diff

local_install:
mkdir -m755 -p $(DESTDIR)$(PYTHON_SITE_DIR)
cp -f freeswitch.py $(DESTDIR)$(PYTHON_SITE_DIR)

I already see where it is going wrong.

I can either change the 2.4 value in the makefile or add the /correct path to site-packages in my PYTHONPATH. I did last and all is working fine now. Thanks.

Reply  |  Options
Unfold Re: voicemail Error importing module by tjaracastjaracas, 1238413526|%e %b %Y, %H:%M %Z|agohover
Re: voicemail Error importing module
stas_shtinstas_shtin 1238416175|%e %b %Y, %H:%M %Z|agohover

I've had this issue before. I think that the problem is caused by invalid sequence of actions in wikipbx install manual: it tells you first to bootstrap & configure freeswitch and later to edit modules.conf. But that means that the modules.conf has default values when configure script is run, so when you build freeswitch with mod_python enabled it uses default values instead of the ones it can detect on your system.

Reply  |  Options
Unfold Re: voicemail Error importing module by stas_shtinstas_shtin, 1238416175|%e %b %Y, %H:%M %Z|agohover
Re: voicemail Error importing module
tjaracastjaracas 1238419260|%e %b %Y, %H:%M %Z|agohover

I think the sequence of events is correct in the manual. My only guess is that is looked for a previously installed 2.4 python version on the system in stead of the newer 2.6 version. I dont think that the sequence of events in the manual is wrong. If you add an additional module to freeswitch you just can make it in the source dir and adding it to modules.conf.xml. No deed to reconfigure the complete application. So somewhere it took the incorrect version for python and put this in the makefile.

Reply  |  Options
Unfold Re: voicemail Error importing module by tjaracastjaracas, 1238419260|%e %b %Y, %H:%M %Z|agohover
Re: voicemail Error importing module
stas_shtinstas_shtin 1238421023|%e %b %Y, %H:%M %Z|agohover

Interesting, I've just checked and looks like python is detected correctly even if it's disabled in modules.conf. So my guess was wrong, although I've experienced such problem some time ago. Can you confirm that running "python -V" doesn't show that you have python 2.4 as default?

Apparently, it should be possible to avoid such error by forcing FS to use an exact version of python by specifying —with-python=/path/to/python/executable flag to configure script.

Reply  |  Options
Unfold Re: voicemail Error importing module by stas_shtinstas_shtin, 1238421023|%e %b %Y, %H:%M %Z|agohover
New Post
page_revision: 0, last_edited: 1226259295|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License