Using Asterisk 16.2.1 my AGI
script (at the bottom) works with python2 #!/usr/bin/env python2
, but not with python3 #!/usr/bin/env python3
.
I do not even get as far as agi.verbose("python agi started")
(with python3), so I assume it has something to do with the AGI import or initialization agi = AGI()
Having used agi set debug on
does not really help, the only info I see is
Launched AGI Script /home/.../asteriskAgi.py
-- <SIP/..-00000002>AGI Script /home/.../asteriskAgi.py completed, returning 0
As it works with python2, but not 3 I have also installed pyst3
from https://pypi.org/project/pyst3/ , but it did not help (it does not work with or without pyst3
installed).
Q: Any idea how to configure asterisk
for python3, or how to find the root cause?
Any chance to get more detailed log information of where the script actually fails_
#!/usr/bin/env python3
import sys
import rpyc
from asterisk.agi import AGI
agi = AGI()
agi.verbose("python agi started")
aCallerId = agi.env['agi_callerid']
aType = agi.env["agi_type"]
agi.verbose("XXXXXXXXXXXXXX call from %s" % aCallerId)
agi.verbose(sys.executable)
l = [aCallerId, aType]
agi.verbose("XXXXXXXXXXXXXX l")
c = rpyc.connect("localhost", 18861)
c.root.asteriskCall(l)
Even this minimalistic version does not work with "3"
#!/usr/bin/env python3
import rpyc
from asterisk.agi import AGI
agi = AGI()
agi.verbose("python agi started")
eventually solved by:
pyst3
and pyst2
like pip3 install --upgrade --force-reinstall pyst2
. No idea what went wrong in the first place.Your minimalistic version works for me(with pyst2 installed via pip)
Check permission and installed packages. Also ensure that your asterisk running under environment which able find python3 and packages installed.