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

运行StreamLit报pyarrow.lib导入错误,单独导入numpy无异常如何解决?

排查步骤
  • 验证环境一致性:单独运行脚本和启动Streamlit使用的可能是不同Python虚拟环境,分别在两个场景下输出numpy信息确认:
    测试脚本中加入以下代码运行:
    import numpy
    print(numpy.__version__)
    print(numpy.__file__)
    
    在启动Streamlit的终端中执行以下命令:
    # Linux/macOS执行
    which python
    # Windows执行
    where python
    
    python -c "import numpy;print(numpy.__version__);print(numpy.__file__)"
    
    若两次输出的版本、安装路径不一致,即可定位是环境不匹配问题,Streamlit调用的环境中numpy版本不符合pyarrow的依赖要求。
  • 检查依赖兼容性:执行pip check命令,可直接检测当前环境中是否存在pyarrow和numpy版本不匹配的问题。
  • 排查numpy安装完整性:部分场景下numpy安装过程中出现编译文件损坏,单独导入不会触发异常,但被pyarrow调用时会报错。
解决方案
  • 环境不匹配场景:切换到Streamlit使用的Python环境,重新安装完整依赖:
    pip uninstall -y numpy pyarrow
    pip install numpy pyarrow streamlit
    
  • 版本不兼容场景:安装经过兼容性验证的版本组合:
    pip install numpy==1.23.5 pyarrow==12.0.1
    
  • 临时规避方案:如果暂时无法修复依赖问题,可在Streamlit脚本开头加入代码禁用pyarrow相关缓存:
    import streamlit as st
    st.config.set_option("server.fileWatcherType", "none")
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.09 10:15:03