A Python Lambda cannot load cryptography because glibc is too old
Fix it fast
Most common cause, 1 of 3Dependencies were installed on a newer Linux and zipped as they were
Reinstall the packages for the Lambda platform, not for the build host, using the manylinux2014 tag AWS gives for Amazon Linux 2 runtimes.
rm -rf package && mkdir package
pip install \
--platform manylinux2014_x86_64 \
--target=package \
--implementation cp \
--python-version 3.11 \
--only-binary=:all: --upgrade \
-r requirements.txt
(cd package && zip -r ../function.zip .) && zip function.zip lambda_function.py
aws lambda update-function-code --function-name my-function --zip-file fileb://function.zipShort answer
GLIBC_2.28 not found in a Python Lambda means the package holds a manylinux_2_28 (or newer) wheel, such as cryptography's Rust module, while python3.11 and older runtimes run on Amazon Linux 2 with glibc 2.26. Reinstall with pip --platform manylinux2014_x86_64 --only-binary=:all:, or move the function to python3.12 or later, which runs on Amazon Linux 2023 with glibc 2.34.
Which cause do you have?
Compare the function's runtime with the platform tag of the wheel you packaged. A python3.11 or older runtime with a manylinux_2_28 or manylinux_2_34 tag is the mismatch; a /opt/python path in the error means the wheel came in through a layer.
aws lambda get-function-configuration --function-name my-function --query "[Runtime, Architectures]"
grep -h "^Tag:" package/cryptography-*.dist-info/WHEELThen find the line you see in this list and open its fix:
- 1Dependencies were installed on a newer Linux and zipped as they were
The WHEEL file shows a manylinux_2_28 or manylinux_2_34 tag, and the runtime is python3.11 or python3.10 - 2The package no longer publishes manylinux2014 wheels
pip with --platform manylinux2014_x86_64 and --only-binary=:all: finds no matching distribution, or falls back to a much older release - 3A Lambda layer was built on macOS, Windows or another Linux
The path in the error starts with /opt/python, so the failing file comes from a layer, not from your function zip
What does the error look like?
/lib64/libc.so.6: version `GLIBC_2.28' not foundPython 3.11 upgrade - lib64/libc.so.6: version `GLIBC_2.28' not found
Cause 1 of 3
Dependencies were installed on a newer Linux and zipped as they were
You seeThe WHEEL file shows a manylinux_2_28 or manylinux_2_34 tag, and the runtime is python3.11 or python3.10
Check
Without --platform, pip chooses wheels that suit the machine it runs on. A current CI runner or Docker image has a recent glibc, so it can end up with a manylinux_2_28 or manylinux_2_34 wheel. AWS documents that Python 3.11 and earlier Lambda runtimes are built on Amazon Linux 2, which ships glibc 2.26, too old for those wheels.
ls package/ | grep -i dist-infoFix
Reinstall the packages for the Lambda platform, not for the build host, using the manylinux2014 tag AWS gives for Amazon Linux 2 runtimes. Set --python-version to the runtime's version and repeat with manylinux2014_aarch64 for arm64 functions.
rm -rf package && mkdir package
pip install \
--platform manylinux2014_x86_64 \
--target=package \
--implementation cp \
--python-version 3.11 \
--only-binary=:all: --upgrade \
-r requirements.txt
(cd package && zip -r ../function.zip .) && zip function.zip lambda_function.py
aws lambda update-function-code --function-name my-function --zip-file fileb://function.zipVerify
The WHEEL tag now reads manylinux2014 (manylinux_2_17), and a test invoke imports the module without the GLIBC error.
aws lambda invoke --function-name my-function response.json && cat response.jsonConfirmed by docs.aws.amazon.com
Cause 2 of 3
The package no longer publishes manylinux2014 wheels
You seepip with --platform manylinux2014_x86_64 and --only-binary=:all: finds no matching distribution, or falls back to a much older release
Check
AWS notes that many Python packages have stopped publishing manylinux2014 wheels in favour of manylinux_2_28. An Amazon Linux 2 runtime cannot load those. The same Lambda docs say Amazon Linux 2 reached end of life on 30 June 2026, and the python3.11 runtime is scheduled for deprecation on 30 June 2027.
pip download --no-deps --platform manylinux2014_x86_64 --implementation cp --python-version 3.11 --only-binary=:all: -d /tmp/wheels <package_name>Fix
Move the function to python3.12 or later. Those runtimes are built on Amazon Linux 2023 with glibc 2.34, so manylinux_2_28 wheels load. Install with the manylinux_2_28 tag and the new Python version, then change the runtime setting.
pip install \
--platform manylinux_2_28_x86_64 \
--target=package \
--implementation cp \
--python-version 3.14 \
--only-binary=:all: --upgrade \
-r requirements.txt
aws lambda update-function-configuration --function-name my-function --runtime python3.14Verify
get-function-configuration shows the new runtime, and the function starts and imports every package.
aws lambda get-function-configuration --function-name my-function --query RuntimeConfirmed by docs.aws.amazon.com
Cause 3 of 3
A Lambda layer was built on macOS, Windows or another Linux
You seeThe path in the error starts with /opt/python, so the failing file comes from a layer, not from your function zip
Check
Layer packages must be Linux builds that fit the runtime, and compiled packages built on macOS or Windows need the --platform flag to get a Linux wheel. A layer built on a newer Linux has the same glibc gap as cause 1.
unzip -l layer.zip | grep -i "_rust\|dist-info/WHEEL"Fix
Rebuild the layer into a python folder with the platform tag that matches the runtime, publish a new layer version, and attach that version to the function.
rm -rf python && pip install -r requirements.txt --platform manylinux2014_x86_64 --only-binary=:all: -t python/
zip -r layer.zip python
aws lambda publish-layer-version --layer-name my-layer --zip-file fileb://layer.zip --compatible-runtimes python3.11Verify
The function runs on the new layer version without the import error.
aws lambda invoke --function-name my-function response.jsonConfirmed by docs.aws.amazon.com
How do I stop it coming back?
- Put the --platform, --python-version and --only-binary=:all: flags in the build script itself, so every machine builds the same zip.
- Plan the move off python3.11 now; its Amazon Linux 2 base is past end of life and the runtime has a published deprecation date.
- Add a CI step that greps every dist-info WHEEL tag and fails when it is newer than the runtime's glibc allows.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Dispatch Pro, stegnor.com, Menulo.