I used pip to install a Python package that contains compiled code, but my deployment package isn't compatible with AWS Lambda. How do I fix that?

There are Python packages that contain compiled code, for example NumPy. You can install these packages using the pip install command:

pip install module-name -t /path/to/project-dir

However, if you install these packages using pip, the packages will download and compile a module-name package for your architecture. This makes your deployment package incompatible with Lambda unless you run the command in a Linux operating system.

To make a deployment package that's compatible with Lambda, download a precompiled package called a wheel (.whl). Uncompress the wheel file on /path/to/project-dir instead of using pip install.  

1.    Open your module-name pypi.org page. For example:

https://pypi.org/project/numpy/

2.    Choose Download files.

3.    Download:

  • For Python 2.7, module-name-version-cp27-cp27mu-manylinux1_x86_64.whl
  • For Python 3.6, module-name-version-cp36-cp36m-manylinux1_x86_64.whl

4.    Uncompress the wheel file on the /path/to/project-dir folder.

When the wheel file is uncompressed, your deployment package will be compatible with Lambda.


Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2018-09-18