无法导入模块'lambda_function':无法从'ctypes'(/var/lang/lib/python3.7/ctypes/__init__.py [英] Unable to import module 'lambda_function': cannot import name 'WinDLL' from 'ctypes' (/var/lang/lib/python3.7/ctypes/__init__.py

查看:95
本文介绍了无法导入模块'lambda_function':无法从'ctypes'(/var/lang/lib/python3.7/ctypes/__init__.py的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在python lambda函数中使用matplotlib生成图形.我使用mathplotlib库导入了一个图层,但是它不起作用.这个想法是生成一个图形,将其保存为临时文件,然后上传到S3.

I'm trying to generate a graph with matplotlib in python lambda function. i imported a layer with the library mathplotlib, but it doesn't work. The idea is generate a graph, save it like temp file and upload to S3.

运行代码时,输​​出为:

When i run the code, the output is:

Response:
{
  "errorMessage": "Unable to import module 'lambda_function': cannot import name 'WinDLL' from 'ctypes' (/var/lang/lib/python3.7/ctypes/__init__.py)",
  "errorType": "Runtime.ImportModuleError"
}

帮助!

我需要安装另一个图书馆吗?我看到这是numpy库的问题,但我不知道.

I need intall another library? I saw that is a problem with numpy library, but i don't know.

存在另一个库来生成图形吗?

Exist another library to generate graphs?

推荐答案

我假设您使用Windows操作系统打包了python库(通过virtualenv),并将它们作为zip文件上传到AWS-Lambda的create function部分.

I assume you used a windows OS to package your python libraries (via virtualenv) and uploaded them as a zip file in the create function section of AWS-Lambda.

AWS是基于Linux的,因此不兼容可能源于您将库打包在Windows上的事实.

AWS is linux based so the incompatibility might stem from the fact that you packaged your libraries on windows.

基本上,您需要在linux机器中进行包装.也许使用了免费版本的ec2-linux.而且,matplotlib库有其自身的兼容性问题,因此无法真正保证这种方法会起作用.

Basically, you would need to do the packaging in a linux machine. Maybe using a free tier version of ec2-linux. Moreover, the matplotlib library has it's own compatibility issues so there is no real guarantee that this approach will work.

希望这对您有帮助

这篇关于无法导入模块'lambda_function':无法从'ctypes'(/var/lang/lib/python3.7/ctypes/__init__.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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