aws / aws-lambda-base-images

Apache License 2.0
648 stars 107 forks source link

Python 3.8 base image - `pip` cannot import `MappingProxyType` #49

Open ividito opened 2 years ago

ividito commented 2 years ago

Been receiving the following error when building our container.

#9 0.245 Traceback (most recent call last):
#9 0.245   File "/var/lang/bin/pip", line 3, in <module>
#9 0.245     import re
#9 0.245   File "/var/lang/lib/python3.8/re.py", line 124, in <module>
#9 0.245     import enum
#9 0.245   File "/var/lang/lib/python3.8/enum.py", line 2, in <module>
#9 0.245     from types import MappingProxyType, DynamicClassAttribute
#9 0.245 ImportError: cannot import name 'MappingProxyType' from 'types' (/var/lang/lib/python3.8/types.py)
------
executor failed running [/bin/sh -c pip install boto3]: exit code: 1

Error can be reproduced using this Dockerfile:

FROM public.ecr.aws/lambda/python:3.8

RUN mkdir -p ${LAMBDA_TASK_ROOT}/
RUN pip install boto3

The error seems to occur on any pip command in our Dockerfile, regardless of the requirements.txt or packages provided.

I noticed that the ECR image was updated today, and changing our Dockerfile to use FROM public.ecr.aws/lambda/python:3.8.2022.05.09.14 resolved the issue.

smirnoal commented 1 year ago

does it work for you with the :latest image?