skip to Main Content

I’m trying to run a script in python from the freeswitch dialplan. This scripts has calls to a local REDIS DB which I need to query every time a call arrives.
So far I was able to compile freeswitch with mod_python, I even can run a test.py script from the fs_cli like this:

freeswitch@reverse> python test
2021-06-25 16:36:36.007177 [NOTICE] mod_python.c:213 Invoking py module: test
2021-06-25 16:36:36.027120 [INFO] switch_cpp.cpp:1465 test
Hello

But when  try to add in the test.py the “import redis” line in order to work with my redis db  I’m getting : 

freeswitch@reverse> python test
2021-06-25 16:37:17.847161 [NOTICE] mod_python.c:213 Invoking py module: test
2021-06-25 16:37:17.847161 [ERR] mod_python.c:261 Error reloading module


2021-06-25 16:37:17.847161 [ERR] mod_python.c:165 Python Error by calling script "test": <type 'exceptions.ImportError'>
Message: No module named redis
Exception: None

Traceback (most recent call last)
        File: "/usr/share/freeswitch/scripts/test.py", line 1, in <module>

Maybe I’m not getting correctly the use of pythons scripts?.. Can I use a script that calls another module?… Is possible?
Or maybe there is a better way to do this?.

Thanks!

2

Answers


  1. Chosen as BEST ANSWER

    Thanks!.

    In fact the problem was another... I was calling a Python 3.6 script instead of Python 2.7... in the python3.6 was the redis for Python installed ok.. but not for Python 2.7.. so I installed redis using "pip" and it started to work ok.


  2. install redis module first

    # example for centos
    yum install python-redis
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search