You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

RHEL8下WSGI环境调用pd.read_sql报AttributeError问题排查

WSGI环境下Pandas 1.1.5报AttributeError: 'module' has no attribute 'read_sql'的排查与根因

问题场景

环境:Python 3.6(RHEL 8)、Pandas 1.1.5
执行代码:

pd.read_sql(<my query>, conn).to_dict(orient="records")

抛出错误:

AttributeError: module 'pandas' has no attribute 'read_sql'

异常特征

  • 命令行执行python3 -c "import pandas; print(str(pandas.__dict__))",可明确看到read_sql函数存在
  • 卸载重装Pandas后问题未解决
  • 仅在WSGI环境触发错误,非WSGI的测试服务器运行正常

排查结论

对比WSGI环境与测试服务器的Python路径、pandas.__dict__内容后,定位到真实根因:
RHEL 8系统上,Pandas依赖的numpy与mod_wsgi存在兼容性冲突,且Python未将该兼容性错误输出,最终表现为read_sql属性找不到的异常。

内容的提问来源于stack exchange,提问作者Wige

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 09:53:00