无法将Pyodbc与AWS Lambda和API Gateway一起使用 [英] Unable to use pyodbc with aws lambda and API Gateway

查看:97
本文介绍了无法将Pyodbc与AWS Lambda和API Gateway一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Api网关构建一个AWS Lambda函数,该函数会使用pyodbc python软件包.我已按照文档中提到的步骤进行操作.我不断收到以下错误无法导入模块'app':libodbc.so.2:无法打开共享对象文件:测试运行Lambda函数时,没有这样的文件或目录.

I am trying to build a AWS Lambda function using APi Gateway which utlizes pyodbc python package. I have followed the steps as mentioned in the documentation. I keep getting the following error Unable to import module 'app': libodbc.so.2: cannot open shared object file: No such file or directory when I test run the Lambda function.

任何帮助表示赞赏.我使用Chalice部署程序包时遇到了相同的错误.看来可能是我需要安装unixodbc-dev.知道如何通过AWS Lambda做到这一点吗?

Any help appreciated. I am getting the same error when I deployed my package using Chalice. It seems it could be that I need to install unixodbc-dev. Any idea how to do that through AWS Lambda?

推荐答案

pyodbc使用一些本机库.因此,您不能仅将site-packages的内容复制到Lambda,因为您的操作系统可能不是Amazon Linux.

pyodbc uses some native libs. Therefore you cannot just copy the contents of your site-packages to Lambda, as your OS is likely not Amazon Linux.

因此,您需要在Amazon Linux实例上安装pyodbc并使用生成的库:

So you need to install pyodbc on an Amazon Linux instance and use the generated libs:

https ://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html

或者如果可以的话,也可以从这里获得:

Or you can get from here, if available there:

https://github.com/Miserlou/lambda-packages

这篇关于无法将Pyodbc与AWS Lambda和API Gateway一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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