【发布时间】:2019-02-04 21:25:17
【问题描述】:
我正在尝试从我的 Windows 机器编译 numpy 以用于 AWS Lambda 函数。
我一直在关注this serverless-python-requirements 的简单示例,让 lambda 打印一个 numpy 数组。
我在本地目录 ../numpy-test 的 virtualenv 中运行 serverless deploy
(numpy-test) C:\Users\...\numpy-test>serverless deploy
Serverless: Generated requirements from C:\Users\...\numpy-test\requirements.txt in C:\Users\...\numpy-test\.serverless\requirements.txt...
Serverless: Installing requirements from C:\Users\...\numpy-test\.serverless\requirements\requirements.txt ...
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Injecting required Python packages to package...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (42.86 MB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
我的 requirements.txt 文件只包含
numpy==1.13.1
我的 YML 文件看起来像:
service: numpy-test
frameworkVersion: ">=1.1.0 <2.0.0"
plugins:
- serverless-domain-manager
- serverless-python-requirements
custom:
pythonRequirements:
dockerizePip:non-linux
stage: ${opt:stage, self:provider.stage}
domains:
prod: ...
staging: ...
dev: ...
当我在使用serverless invoke -f numpy --log 上传后尝试测试功能时,出现以下错误
"errorMessage": "Unable to import module 'handler'"
}
--------------------------------------------------------------------
START RequestId: 24584f5c-5145-4694-b21b-7c6e4700f985 Version: $LATEST
Unable to import module 'handler':
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: cannot import name 'multiarray'
当我直接从 AWS lambda 下载依赖项时,看起来该包是在 Windows 中编译的。
我已经安装了 Docker,据我所知它工作正常。我以前没有使用过它,所以我尝试使用这个解决方案,而不是在 Docker 中学习很多新命令。
出了什么问题?
【问题讨论】:
标签: numpy docker python-3.6 serverless-framework aws-serverless