4

I have created a Deployment Package for AWS Lambda, written in Python 2.7. In the Python script, I use pypyodbc to connect to an external data source, using a User DNS that I have configured on my local machine. When I attempt to deploy the package, I get the following error:

module initialization error: 'ODBC Library is not found. Is LD_LIBRARY_PATH set?'

I created the package project-dir using pip into a virtual environment. The package is arranged as follows:

/project-dir
  __init__.py
  PythonFileIWantToUse.py
  pypyodbc.py
  pypyodbc.pyc
  /boto
  /pypyodbc-1.3.3.dist-info
  /other modules, etc.

I've tried adding

#Point Lambda to Required OBDC Directory os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + ':' + '/var/task/'

to MainPythonIWantToUse.py above the lambda_handler function, and including odbc32.lib in the root directory, but I got the same error.

Any idea what I need to do? I configured a local ODBC in Windows, but I'm not sure what file(s) to put where for Lambda's Unix Environment to find them.

Edit: I've tried to include the elements of UnixODBC in the root directory as well, but this doesn't change the result.

user2752159
  • 1,182
  • 3
  • 13
  • 29
  • Just wondering of you ever got this working...I'm also stuck. – Ryan Jones Sep 29 '16 at 17:08
  • I believe you need to use Linux ODBC drivers: See here: http://stackoverflow.com/questions/33588262/tesseract-ocr-on-aws-lambda-via-virtualenv – Metoo Jan 16 '17 at 19:11
  • Hey, you should check https://stackoverflow.com/questions/47682991/aws-lambda-function-to-connect-to-sql-server-with-python – Carlochess Aug 31 '18 at 22:26

0 Answers0