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

AWS Lambda Layer(Python 3.11)迁移后cryptography库_rust.abi3.so文件缺失导致Runtime.ImportModuleError问题求助

AWS Lambda Layer(Python 3.11)迁移后cryptography库_rust.abi3.so文件缺失导致Runtime.ImportModuleError问题求助

大家好,我最近在把AWS Lambda的Python运行时从3.8升级到3.11后,遇到了一个棘手的问题——用AWS SAM部署的Lambda Layer抛出了Runtime.ImportModuleError错误,具体报错信息如下:

Runtime.ImportModuleError: Unable to import module 'signin': /opt/python/cryptography/hazmat/bindings/_rust.abi3.so: cannot open shared object file: No such file or directory

这个错误是在调用Lambda函数时触发的,明确指向Layer里的cryptography库缺失了_rust.abi3.so文件,而问题是从迁移到Python 3.11之后才出现的。

下面是我的buildspec.yaml里的关键配置(省略了部分无关内容):

version: 0.2

phases:
  install:
    runtime-versions:
      python: 3.11
    commands:
      # ... 其他安装命令 ...
  pre_build:
    commands:
      # ... 其他预构建命令 ...
      - cd lambda_layers/global_utils/python
      - pip install -r requirements.txt -t .
      - cd ../../
      # ... Node相关的构建命令 ...
  build:
    commands:
      - echo "Starting SAM packaging `date` in `pwd`"
      - aws cloudformation package --template-file template.yaml --s3-bucket $BUILD_OUTPUT_BUCKET --output-template-file package.yaml

我已经尝试过几个方向,但都没能解决问题:

  • 调整pip install的参数,比如添加--platform manylinux2014_x86_64或者--only-binary=:all:
  • 将Lambda函数的架构从x86切换到ARM
  • 回退到Python 3.8运行时的话,一切正常,但我希望能顺利升级到3.11

有没有大佬遇到过类似的问题?或者能给我一些排查和解决的方向?非常感谢!

备注:内容来源于stack exchange,提问作者mubtasimfuad

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.21 15:44:33