aws-sam-cli: Build failed - Error: PythonPipBuilder:ResolveDependencies
Description
Trying to create Python Lambda function from PyCharm not working
Steps to reproduce
Invoke Lambda creation using “Create new AWS Lambda…” Runtime: Python 3.7 requirements.txt: https://pastebin.com/HpU1it63 Run using strict template file: template.yml:
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Serverless Specification template describing your function.
Resources:
test3:
Type: 'AWS::Serverless::Function'
Properties:
Handler: order.create_order
Runtime: python3.7
CodeUri: .
Description: ''
MemorySize: 128
Timeout: 300
Role: 'arn:aws:iam::123456789:role/service-role/test-role'
VpcConfig:
SecurityGroupIds:
- sg-62e1c42f
SubnetIds:
- subnet-26e9c26e
- subnet-68a3c632
- subnet-b8edb5de
Observed result
Used graphical create, not CLI, error:
Build Failed
Error: PythonPipBuilder:ResolveDependencies - {msgpack-python==0.5.6(sdist), pyrsistent==0.15.7(sdist), simplejson==3.17.0(wheel), pyyaml==5.3(sdist)}
Full log: https://pastebin.com/asgCa9D4
Expected result
Successful build
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
OS: macOS Mojave 10.14.6 SAM: SAM CLI, version 0.43.0 P: Python 3.7.6 IDE: PyCharm 2019.3 AWS: aws-cli/2.0.1 Python/3.7.4 Darwin/18.7.0 botocore/2.0.0dev5 used wheel: wheel 0.34.2 used pip: pip 19.0.3
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 2
- Comments: 43 (7 by maintainers)
got the following error started appearing during
sam build
SAM CLI, version 1.20.0 Python 3.8.7 pip 21.1.2
--use-container
doesn’t solve the problem.This fixed the ResolveDependencies error for me
pip install wheel
I solved this using
sam build --use-container
, however this works only when template.yml file is present. Using the graphical form does not allow to insert --use-container and it fails, so I do not count this as a solution, but workaround instead… // Also since I am unable to build app locally in my IDE, I am unable to run/debug it, so it makes no sense to use this workaround.I’m seeing something similar:
Both pyyaml & pyrsistent are inside my requirements.txt file, which have been installed inside a virtualenv.
wheel is installed.
--use-container
also fails with a similar error but with different deps. I tried creating a brand new project which worked fine. So, it’s probably something within my project that is messed up.I think I was able to get little more insight into the issue.
MacOS + pyenv
so the expectation would be following to work
After some digging around did this: edit
/usr/local/Cellar/aws-sam-cli/1.37.0/site-packages/aws_lambda_builders/workflows/python_pip/packager.py
line 658before or after
invoke_pip = [self.python_exe, "-c", exec_string]
addedprint(self.python_exe)
to my surprise it was pointing to
/Users/XYZ/.pyenv/shims/python3.8
ran
/Users/XYZ/.pyenv/shims/pip3.8 install wheel
and then
sam build
and it worked.Please check and confirm here if this works for you too.
My set of tricks to make it work on Apple M1 (MacOS 11.6 Big Sur)
Check versions:
Build the project with
sam build
and it should work now. Although, it still cannot build in containers when using Podman due to the separate issue.This definitely worked for me. But, could someone explain why is this needed? It would be great if it worked out of the box
I was running into
Error: PythonPipBuilder:ResolveDependencies - {cytoolz==0.11.0(wheel)}
with sam 0.45.0. Upgrading sam to latest (1.27.2) solved itJust add some extra insights here.
sam project structure as follows: |- template.yaml |- samconfig.toml HelloWorld — |- requirements.txt — |- mymodule ------- |- setup.py ------- |- setup.cfg ------- |- src ------------|- code --------------- |- __init__.py --------------- |- code.py
I am using a local module and declare it as “-e relative/path” at requirements.txt.
The problem is that the relative path declared is very tricky.
When
sam build --use-container
from the project root, it should be-e mymodule/
. Otherwise it would causePythonPipBuilder:ResolveDependencies
, yet-e mymodule/
wouldn’t work the same whensam build
from the project root.Glad you were able to resolve this! FWIW I’ve seen this periodically with Python builds especially,
pip
seems to be very sensitive to encoding issues. Unfortunately, nothing we can do on our end about that.Thanks for coming back to me. You are right it was an encoding issue of the requirements.txt file. To check it I opened it and printed the encoding info.
f=open('requirements.txt, 'w') print(f.encoding)
The result was cp1252.
I altered this by changing it in the Windows control panel
Control panel (make sure you are set to category view)> Clock and Region > Region > Adminsitrative > Change System Locale
and ticked the box that says ‘Beta: Use Unicode UTF-8 for worldwide language support’. Following a restart, my encoding had changed to ‘cp65001’ which I believe is equivalent to UTF8 and I was able to create my Lambda Function.
I have the same issue. Tried installing wheel, using --use-container, updating sam to 1.31. None is helpful.
The most weird thing is it was working last week, but suddenly broke today. Nothing has changed at all!
I’m having the same issue
sam build --use-container --template ./my_template.yaml --debug
produces
Error: PythonPipBuilder:ResolveDependencies - Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-download-ufgf7ow5/fastparquet/
However, installing the requirements.txt with pip in the host machine produces no error.
I also tried to update my sam version from 1.27.2 -> 1.31.0 and I get the same error.
+1
My current workaround is to manually add
grpcio
to therequirements.txt
file, but fixed to an older version.It seems to fail with version 1.28.
Same. It seems like it fails to build anything with tensorflow or better yet grpcio
Do you have wheel installed? if not
sam build --use-container
may be the best bet.