I've recently started working with AWS and built my first Lambda function using Python 3.13. I've read that I can include dependencies through layers. My current process involves creating a virtual environment locally, installing the necessary packages, and then copying them into a 'python' folder at the root of a zip file. I've seen suggestions that I should also add my lambda_function.py to the root of the zip, but I'm not sure why that's necessary. Do I need to update the layer zip every time I modify the function code? Although it worked for most packages without the lambda_function.py, I'm facing issues with the cryptography package. The error I keep getting is: 'cannot import name 'exceptions' from 'cryptography.hazmat.bindings._rust' (unknown location)'. I've read that cryptography is dependent on the architecture of the machine it's built on, which complicates things since I can't just package it on my Windows machine for use in Lambda's Linux environment. Is there a method to create a Linux-compatible layer on Windows? I'd prefer not to dive into Docker if I can avoid it, but I'm open to suggestions! Thanks for any guidance!
3 Answers
Have you tried using the AWS SAM CLI? It can actually build the Lambda layers for you by simulating the Linux environment in a container. This can save you a lot of hassle related to compatibility issues!
One effective way to handle this is by using the command `--platform --only-binary=:all:` to get the right binary wheel, like `manylinux1_x86_64`. However, if you can, I’d highly recommend setting up a Docker container that mimics the Lambda runtime environment. This approach helps avoid issues with executable permissions that can arise from Windows filesystems. Trust me, it makes things much smoother!
If you're looking for the simplest route, just install Windows Subsystem for Linux (WSL). It’s a great way to get a Linux environment right on your Windows machine. Alternatively, if you want to go all-in, you could consider removing Windows entirely and setting up a dedicated Linux workstation for your development. Just a thought!

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically