【问题标题】:Freeswitch run python script from dialplanFreeswitch 从拨号计划运行 python 脚本
【发布时间】:2021-06-29 15:08:34
【问题描述】:

我正在尝试从 freeswitch dialplan 在 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>

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

谢谢!

【问题讨论】:

    标签: python freeswitch


    【解决方案1】:

    先安装redis模块

    # example for centos
    yum install python-redis
    

    【讨论】:

      【解决方案2】:

      谢谢!

      事实上,问题是另一个...我调用的是 Python 3.6 脚本而不是 Python 2.7...在 python3.6 中,Python 的 redis 安装好了..但 Python 2.7 没有...所以我安装了redis 使用“pip”,它开始工作正常。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-25
        • 1970-01-01
        • 1970-01-01
        • 2020-08-07
        相关资源
        最近更新 更多