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

Azure函数numpy C扩展导入失败,已尝试常见操作后的调试建议

解决Azure函数中numpy导入失败的问题

问题本质

错误提示里的libopenblas64_p-r0-742d56dc.3.20.so找不到,是因为Azure Functions的Linux基础镜像缺少系统级的OpenBLAS库,numpy的C扩展依赖这个库运行,和你重装、降级numpy的操作无关。

下一步调试及解决方法

  • 强制安装纯Python版numpy:修改requirements.txt,添加带源码编译参数的numpy指定项:
    numpy==1.21.0 --no-binary :all:
    pandas
    
    这样部署时会从源码编译numpy,自动使用纯Python实现的线性代数模块,绕开对系统OpenBLAS库的依赖。
  • 构建自定义Docker镜像:如果需要保留预编译numpy的性能优势,创建包含OpenBLAS库的自定义镜像。编写Dockerfile:
    FROM mcr.microsoft.com/azure-functions/python:4-python3.9
    RUN apt-get update && apt-get install -y --no-install-recommends libopenblas-dev
    COPY requirements.txt /tmp/requirements.txt
    RUN pip install --no-cache-dir -r /tmp/requirements.txt
    COPY . /home/site/wwwroot
    
    用这个镜像部署Azure函数,确保系统库提前安装。
  • 本地Linux环境验证:在本地用Ubuntu 20.04(与Azure Functions官方镜像一致的系统)搭建Python3.9环境,安装相同版本的numpy和pandas,复现错误后,执行sudo apt-get install libopenblas-dev测试是否解决,确认后再同步到Azure部署流程。
  • 检查部署依赖路径:如果用本地打包部署,确保打包时没有遗漏依赖文件,但注意系统级库无法通过pip打包,所以优先用前两种方法。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 03:31:05