Freeswitch 从拨号计划运行 python 脚本

时间:2021-06-29 15:08:34

标签: python freeswitch

我正在尝试从 freeswitch 拨号计划在 python 中运行脚本。该脚本调用了本地 REDIS 数据库,每次有呼叫到达时我都需要查询该数据库。 到目前为止,我已经能够使用 mod_python 编译 freeswitch,我什至可以像这样从 fs_cli 运行 test.py 脚本:

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>

也许我没有正确使用pythons脚本?..我可以使用调用另一个模块的脚本吗?...可能吗? 或者也许有更好的方法来做到这一点?

谢谢!

2 个答案:

答案 0 :(得分:1)

先安装redis模块

# example for centos
yum install python-redis

答案 1 :(得分:0)

谢谢! 事实上,问题是其他......我正在调用一个python3.6脚本而不是python2.7......在python3.6中,pyhton的redis安装好了......但没有安装python2.7......所以在安装redis 使用“pip”并开始正常工作。