我在lambda函数中有以下非常简单的python代码:
from sklearn.externals import joblib
import praw
import datetime
from operator import attrgetter
import sys
def handler_name(event, context):
return "I am a cat dog and i meow."
我还在python 2.7 virtualenv中为scikit-learn,praw,datetime,numpy和scipy做了pip安装。然后我将.py文件和virtualenv的/lib/python2.7/site-packages文件夹中的所有内容压缩成zip并将其上传到AWS lambda。不幸的是,当我运行代码时,我收到以下错误:
Unable to import module 'mainLambda': /var/task/sklearn/__check_build/_check_build.so: invalid ELF header
___________________________________________________________________________
Contents of /var/task/sklearn/__check_build:
setup.py _check_build.so __init__.pyc
__init__.py setup.pyc
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.
If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.
显然问题在于sk-learn。我不知道是什么。它可能是一个版本问题但我从virtulenv中下载了所有库并选择了python2.7 lambda函数。任何的想法?我很难过!