简体   繁体   English

Aws Lambda:部署具有numpy依赖关系的python函数

[英]Aws Lambda: Deploy a python function with numpy dependency

Installed numpy on my project folder using pip install numpy -t <project dir> command. 安装numpy使用我的项目文件夹pip install numpy -t <project dir>命令。 I can see numpy and numpy-1.12.1.dist-info in the project directory. 我可以在项目目录中看到numpynumpy-1.12.1.dist-info
But when I zip the directory and run it on Lambda I get 但是,当我压缩目录并在Lambda上运行它时,我得到了
Unable to import module 'handler': Missing required dependencies ['numpy']

Unable to import module 'handler': Importing the multiarray numpy extension module failed. 无法导入模块“处理程序”:导入多数组numpy扩展模块失败。 Most likely you are trying to import a failed build of numpy. 您极有可能尝试导入失败的numpy构建。 If you're working with a numpy git repo, try git clean -xdf (removes all files not under version control). 如果您使用的是numpy git repo,请尝试使用git clean -xdf (删除所有不受版本控制的文件)。 Otherwise reinstall numpy. 否则,请重新安装numpy。

What is wrong with my project? 我的项目有什么问题?

Check where your numpy is getting installed eg $VIRTUAL_ENV/lib/python2.7/site-packages 检查您的numpy的安装位置,例如$ VIRTUAL_ENV / lib / python2.7 / site-packages

After that follow these steps- 之后,请按照以下步骤操作-

  cd $VIRTUAL_ENV/lib/python2.7/site-packages
  zip -r9 <path_to_your_lambda_function_zip>/awslambda.zip *

This will add all libs in the site-packages into the zip which you can upload directly 这会将站点包中的所有库添加到zip文件中,您可以直接上传该文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM