python - Freeswitch 从拨号计划运行 python 脚本
问题描述
我正在尝试从 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>
也许我没有正确使用pythons脚本?..我可以使用调用另一个模块的脚本吗?...可能吗?或者也许有更好的方法来做到这一点?
谢谢!
解决方案
先安装redis模块
# example for centos
yum install python-redis
推荐阅读
- jupyter-notebook - 为什么我的 Kaggle 笔记本看起来像 JSON
- python - 使用 python 和 Kafka 的 Spark Structured Streaming 给出错误
- html - 将使用无序列表编写的 HTML 表格提取到 Google 表格中
- javascript - 在 jQuery 中识别特定 td 的 tr 的第 n 个孩子
- node.js - 如何使用 Express 将 CSS 和 JS 添加到我的 Node localhost 服务器?
- flutter - Flutter setSystemUIOverlayStyle 启动时不执行
- javascript - JavaScript - 从日期中减去时间
- ios - SwiftUI / 在圆圈中添加照片
- reactjs - 使用 React Router Switch 时取消 React 中的 Axios 请求
- c - C - 图表 - 如何添加根检查以查找关节点