I recently upgraded to Pop OS(essentially Ubuntu) 20.04, which had Python upgraded to 3.8. My ongoing AWS Lambda project build is broken right away:
Running PythonPipBuilder:ResolveDependencies
Build Failed
Error: PythonPipBuilder:ResolveDependencies - Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pip/_internal/main.py", line 14, in main
from pip._internal.utils.entrypoints import _wrapper
File "/usr/lib/python3/dist-packages/pip/_internal/utils/entrypoints.py", line 3, in <module>
from pip._internal.cli.main import main
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
All the solutions from googling the error message seems to be "make sure to run 'apt sudo install python3-distutils'. However, I do have python3-distutils
installed under /usr/lib/python3.8
.
I noticed that the traceback above was produced by pip from python3/dist-packages
, however I do have a later version of pip installed under my .local/lib/python3.8/site-packages
. So why did that not get picked up? The two symptoms together made me think that when SAM runs pip, it's not using the Python 3.8 search path which would contain all the 3.8 packages.
After a couple of hours of pouring through SAM source code and debugging, it turns out SAM was using python 3.7 to build my project, including running pip in, because when I upgraded I only remembered to update Pipfile
to use '3.8', but (completely) forgot to update the '3.7' references in the CloudFormation template file.
While I should obviously take the bulk of the blame for this silly trip, it would have helped if SAM could somehow print something more obvious then the error message I got.
Top comments (0)