Upgrading from Python 3.7 to 3.9


I am working on upgrading some applications we have that are running in AWS Lambda docker images from python 3.7 to python 3.9. The docker images are listed as below:

  • Python 3.7
    • public.ecr.aws/lambda/python:3.7
  • Python 3.9
    • public.ecr.aws/lambda/python:3.9

Previously we were using opencv-python==, however python 3.9 does not support this version so I had to upgrade to the next closest version, which was When doing this upgrade, opencv now compiles from source when trying to pip install.

I am not sure why it is not choosing the appropriate whl file since the linux distro the docker image uses didn’t change (to my knowledge).

Hoping for insight.

Logan Elkins

don’t depend on so old a version.

those old versions don’t have binaries for python 3.9 because python 3.9 wasn’t available then.

none of the files for mention abi3 so they aren’t forward-compatible.

every time pip tries to build from source, you’re trying to match versions that don’t match.

you must pick a newer version. while you’re at it, pick the current release.

Gotcha. We also depend on a large number of other packages so our dependency trees are quite tightly knit but I will do my best to upgrade to a newer version.

Thank you!

if you use aruco, perhaps stop at 4.5.something because after that is when that module was severely manhandled. the dust seems to have settled now though.