无法将cvxpy安装到适用于AWS Lambda的virtualenv中 [英] Unable to install cvxpy into virtualenv for AWS lambda

查看:150
本文介绍了无法将cvxpy安装到适用于AWS Lambda的virtualenv中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在AWS Lambda函数中运行cvxpy软件包。该软件包不在SDK中,因此,我读到必须将依赖项编译为zip,然后将zip上传到lambda函数中。



我已经做了一些研究,并尝试了下面的链接,但是当我尝试点安装cvxpy时,我收到错误消息-我在Windows机器上,但是我知道AWS Lambda在Linux上运行。



感谢帮助!





Lambda函数执行:




I am trying to run the cvxpy package in an AWS lambda function. This package isn't in the SDK, so I've read that I'll have to compile the dependencies into a zip, and then upload the zip into the lambda function.

I've done some research and tried out the links below, but when I try to pip install cvxpy I get error messages - I'm on a Windows box, but I know that AWS Lambda runs on Linux.

Appreciate the help!

http://i-systems.github.io/HSE545/machine%20learning%20all/cvxpy_install/CVXPY%2BInstallation%2BGuide%2Bfor%2BWindows.html

https://programwithus.com/learn-to-code/Pip-and-virtualenv-on-Windows/

https://medium.com/@manivannan_data/import-custom-python-packages-on-aws-lambda-function-5fbac36b40f8

https://www.cvxpy.org/install/index.html

解决方案

For installing cvxpy on windows it requires c++ build tools (please refer: https://buildmedia.readthedocs.org/media/pdf/cvxpy/latest/cvxpy.pdf)

On Windows:

pip install cvxpy --target python/lib/python3.7/site-packages

On Linux:

  • I created the same directory structure as earlier python/lib/python3.7/site-packages and installed the cvxpy and zipped it as shown below.
  • Later I uploaded the zip file to an S3 bucket and created a new lambda layer.
  • Attaching that lambda layer to my lambda function, I colud able to resolve the import issues failing earlier and run the basic cvxpy program on lambda.

mkdir -p alley/python/lib/python3.7/site-packages
pip install cvxpy --target alley/python/lib/python3.7/site-packages
cd alley
zip -rqvT cvxpy_layer.zip .

Lambda layer Image:

Lambda function execution:

这篇关于无法将cvxpy安装到适用于AWS Lambda的virtualenv中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆