0

i have problem with setting up python script on aws lambda function for IBM MQ client. The things I did:

  1. I install IBM MQ client on Ubuntu linux server and there I installed pymqi with pip install pymqi
  2. I zipped MQ installation path (/opt/mqm) and pymqi in same zip file
  3. I uploaded this zip on AWS lambda layer
  4. then I created new lambda function and add layer and wrote in function code "import pymqi"
  5. In enviroment variables I added LD_LIBRARY_PATH = /opt/mqm/lib64

I get next error: "errorMessage": "Unable to import module 'lambda_function': No module named 'pymqe'"

jan
  • 49
  • 9
  • Could be how you are setting `LD_LIBRARY_PATH`. Refer to AWS documentation on how to add to it - https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html - it needs to be set before the pymqi c libraries are built, and also for your lambda function. – chughts Jan 18 '21 at 10:23
  • Can you pleasae tell me what excatly do you mean? :) – jan Jan 19 '21 at 07:59
  • When a pip install of the `pymqi` library is performed, it also creates c object code to interact with. For this compile it needs access to a c compiler, the mq c headers, and object libraries. So all have to be already on the machine, configured and locatable. So `LD_LIBRARY_PATH` needs to be already set. AWS like many cloud platforms limits which environment variables are inherited by spawned systems. Hence you need to read the AWS documentation on setting `LD_LIBRARY_PATH` – chughts Jan 19 '21 at 09:40
  • You resolved this on the pymqi issues list right? Can you post an answer? – JoshMc Feb 07 '21 at 23:15

1 Answers1

0

Here is a similar question: aws lambda Unable to import module 'lambda_function': No module named 'requests'

This bug report on GitHub seems to be similar to your issue: https://github.com/dsuch/pymqi/issues/121

Roger
  • 7,062
  • 13
  • 20
  • weird is because on linux machine pymqi was working, on aws is not. So I did something wrong with uploading to layer. Maybe my path was wrong. In zip file are 2 folders 1 is "python" where pymqi is installed. Second folder is "opt" where ibm mq is installed – jan Jan 16 '21 at 09:25