Unable to import submodules of scipy in AWS Lambda

耗尽温柔 提交于 2019-12-11 10:42:35

问题


I have imported several packages into my AWS Lambda python code. I have scipy installed and seems to be imported correctly using import scipy.However, when I try to import the submodules like from scipy.signal import lfilter , I am unable to import those kind of modules in the Lambda function. I have no clue on why the package import works locally and not on Lambda

Here is a my worker.py

import logging

def lambda_handler(event, context):
    bucket = event['Records'][0]['s3']['bucket']['name']
    key = urllib.unquote_plus(event['Records'][0]['s3']['object']['key']).decode('utf8')

    runFunction(bucket, key)

    try:
        response = s3.get_object(Bucket=bucket, Key=key)
        print("CONTENT TYPE: " + response['ContentType'])
        return response['ContentType']
    except Exception as e:
        print(e)

Here is my handler.py

import sys
try:
  import numpy as np
  print(1)
  import pandas as pd
  print(2)
  from scipy.signal import lfilter
  print(3)
  from uts import io, utils
except Exception, err:
print Exception, err

runFunction(bucket, key)

In this code, I am not able to import from scipy.signal import lfilter. Printing 1 and 2 is fine but the third print statement doesn't work and throws exception.

Here is the exception.

libblas.so.3: cannot open shared object file: No such file or directory

来源:https://stackoverflow.com/questions/35020051/unable-to-import-submodules-of-scipy-in-aws-lambda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!