Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - PIP : Is it possible to specify architecture?

I am building a Python Lambda function code to be executed on AWS (Linux).
My Dev machine is not Linux.
If I do pip install, I am getting Windows/MacOS related modules.

Is there a way to fetch Linux based dependencies always? Such as a CLI argument for target architecture.

like image 655
kn_pavan Avatar asked Jul 31 '26 19:07

kn_pavan


1 Answers

I just had the exact same problem with Lambda, Python, and trying to get Pillow to work. After much searching around, I came across this article that explained the problem, and provided a great solution.

https://medium.freecodecamp.org/escaping-lambda-function-hell-using-docker-40b187ec1e48

Basically, you can run docker on your Mac, which allows you to run a Linux instance. Then using pip, install whatever library you want to use. You can then include those files in your ZIP file and upload it to Lambda. Works like a charm.

These docker images approximate the AWS Lambda environment pretty accurately. You can use them to create packages.

like image 133
James Eberhardt Avatar answered Aug 03 '26 10:08

James Eberhardt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!