2

I have installed asterisk version 1.4.44 and using Python for agi scripts. I have context "9999" than I trying to call while executing this I am getting below errors. is there any dependency to be installed to get this working?

-- Launched AGI Script /var/lib/asterisk/agi-bin/incident/SetCommonVariables.py
Traceback (most recent call last):
File "/var/lib/asterisk/agi-bin/incident/SetCommonVariables.py", line 5, in <module>
from asterisk import agitb
ImportError: No module named asterisk
-- AGI Script incident/SetCommonVariables.py completed, returning 0
-- Executing [s@IncidentInitiation:4] Goto("SIP/9999-00000000", "CheckAuthorization|1") in new stack
-- Goto (IncidentInitiation,CheckAuthorization,1)
-- Executing [CheckAuthorization@IncidentInitiation:1] AGI("SIP/9999-00000000", "incident/CheckAuthorization.py") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/incident/CheckAuthorization.py
Traceback (most recent call last):
File "/var/lib/asterisk/agi-bin/incident/CheckAuthorization.py", line 7, in <module>
from asterisk import agitb

Edit 1 :
Asterisk 1.4.44
CentOS 6.5(Final)
Python version (2.4,2.6.6,2.7)

Edit 2 :

i have already "from asterisk import agitb" in above issues file here code snipes of file File "/var/lib/asterisk/agi-bin/incident/SetCommonVariables.py

#!/usr/bin/python
from IncidentConstants import *
import sys            # system stuff

from asterisk import agitb
agitb.enable(display = False, logdir = '/var/log/asterisk')

# Global variables
from asterisk.agi import *  # our agi stuff
agi = AGI()
agitb.enable(agi, False, '/var/log/asterisk')

in every file i have above content

Hemdip
  • 410
  • 6
  • 29
  • Which OS are you using ? How many python versions are there? How did you install? – oz123 Feb 12 '14 at 05:56
  • OS is cent os 6.5 and asterisk version is 1.4 and python version i have try 2.4,2.6.6 and 2.7 in asterisk cgi i have register one user 9999 and make call that time it show above error in console i have one other post for same issue that link is here http://forums.asterisk.org/viewtopic.php?f=1&t=89276 – Hemdip Feb 12 '14 at 06:07

1 Answers1

2

My guess is that CGI uses the system python. Not the python that has the Asterisk module.

Check that the failing CGI script does not have

#!/usr/bin/python

And if does, change this to use the proper Python.

For each python you have try doing:

from asterisk import agitb

Then you will find which one has asterisk

oz123
  • 27,559
  • 27
  • 125
  • 187
  • I have check in every file. Every file is having above line.the agi scripts are fine because it working on old server i just copy from there. the only difference is old system is uses fedora 7 and new system uses cent os 6.5 (final) – Hemdip Feb 13 '14 at 06:52
  • and when python has asterisk installed? You said you have several Python versions – oz123 Feb 13 '14 at 07:44
  • i have install 2.4,2.6.6 and 2.7 version for try but is seems not solve and currently python 2.6.6 is used – Hemdip Feb 13 '14 at 09:44
  • Issue the line `from asterisk import agitb` in each python you have. I already said that. You need to find which (if any) Python has this module installed. – oz123 Feb 14 '14 at 09:05