Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

A Python Lambda cannot load cryptography because glibc is too old

Your error

/lib64/libc.so.6: version `GLIBC_2.28' not found1 more line it can show

Fix it fast

Most common cause, 1 of 3

Dependencies 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.

Fix
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.zip
Did this fix it?
Full steps for this cause: check, fix, verify

Short 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.

  • Applies to AWS Lambda python3.11 (Amazon Linux 2), AWS Lambda python3.12 to python3.15 (Amazon Linux 2023), cryptography 50.0.2 (manylinux2014, 2_28 and 2_34 wheels)
  • Updated
  • By Maaz Zindani, Senior Software Engineer

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.

Run this first
aws lambda get-function-configuration --function-name my-function --query "[Runtime, Architectures]"
grep -h "^Tag:" package/cryptography-*.dist-info/WHEEL

Then find the line you see in this list and open its fix:

  1. 1Dependencies were installed on a newer Linux and zipped as they wereThe WHEEL file shows a manylinux_2_28 or manylinux_2_34 tag, and the runtime is python3.11 or python3.10
  2. 2The package no longer publishes manylinux2014 wheelspip with --platform manylinux2014_x86_64 and --only-binary=:all: finds no matching distribution, or falls back to a much older release
  3. 3A Lambda layer was built on macOS, Windows or another LinuxThe 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 found
  • Python 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.

Check
ls package/ | grep -i dist-info

Fix

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.

Fix
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.zip

Verify

The WHEEL tag now reads manylinux2014 (manylinux_2_17), and a test invoke imports the module without the GLIBC error.

Verify
aws lambda invoke --function-name my-function response.json && cat response.json

Confirmed by docs.aws.amazon.com

Did this fix it?

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.

Check
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.

Fix
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.14

Verify

get-function-configuration shows the new runtime, and the function starts and imports every package.

Verify
aws lambda get-function-configuration --function-name my-function --query Runtime

Confirmed by docs.aws.amazon.com

Did this fix it?

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.

Check
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.

Fix
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.11

Verify

The function runs on the new layer version without the import error.

Verify
aws lambda invoke --function-name my-function response.json

Confirmed by docs.aws.amazon.com

Did this fix it?

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.

Explained for app owners

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.