Aws-sam-cli: Build failed - Error: PythonPipBuilder:ResolveDependencies

Created on 3 Mar 2020  路  14Comments  路  Source: aws/aws-sam-cli

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

stagmore-info-needed

Most helpful comment

I'm seeing something similar:

$ sam build
Building resource 'PaymentsDataStreamFunction'
Running PythonPipBuilder:ResolveDependencies

Build Failed
Error: PythonPipBuilder:ResolveDependencies - {pyyaml==5.3.1(sdist), pyrsistent==0.15.7(sdist)}

Both pyyaml & pyrsistent are inside my requirements.txt file, which have been installed inside a virtualenv.

All 14 comments

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._

Are you using AWS Toolkit for Pycharm?

I'm seeing something similar:

$ sam build
Building resource 'PaymentsDataStreamFunction'
Running PythonPipBuilder:ResolveDependencies

Build Failed
Error: PythonPipBuilder:ResolveDependencies - {pyyaml==5.3.1(sdist), pyrsistent==0.15.7(sdist)}

Both pyyaml & pyrsistent are inside my requirements.txt file, which have been installed inside a virtualenv.

Do you have wheel installed? if not sam build --use-container may be the best bet.

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.

@c2tarun yes, I am using this plugin

Same here - Used another dep that depends on jsonschema and bumped into this. Can't use --use-container as I have a shared dep two directories up. For that to work I'd need to copy the wheel to every service I have, or have a way to mount a volume during sam build.

Thanks for opening the issue, I'll spend a couple of days rewriting the lib and build a wheel from that instead

I'm getting same issue when I use sam build --use-container (Windows, Python 3.6, SAM CLI version 0.47.0):
Build Failed Error: PythonPipBuilder:ResolveDependencies - {tensorflow==1.15.0(wheel), grpcio==1.28.1(wheel)}

Same. It seems like it fails to build anything with tensorflow or better yet grpcio

My current workaround is to manually add grpcio to the requirements.txt file, but fixed to an older version.

grpcio==1.27.2

It seems to fail with version 1.28.

I'm seeing a similar error with the following in requirements.txt
pyorc==0.2.0

I am running:

sam build --use-container

Output:
Starting Build inside a container
Building resource 'CdcFunction'

Fetching lambci/lambda:build-python3.7 Docker container image......
Mounting /path/to/my/app as /tmp/samcli/source:ro,delegated inside runtime container

Build Failed
Running PythonPipBuilder:ResolveDependencies
Error: PythonPipBuilder:ResolveDependencies - {pyorc==0.2.0(wheel)}

wheel is installed. I'm getting the same error when I add psycopg2 to the requirements.
Here is my template.yaml for reference

Globals:
  Function:
    Timeout: 180

Resources:
  CdcFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: lambda/
      Handler: lambda.lambda_handler
      Runtime: python3.7

+1

+1

Error: PythonPipBuilder:ResolveDependencies - {pyrsistent==0.16.0(sdist), pyyaml==5.1.2(sdist)}

If your dependencies have C bindings involved, building within the container is the way forward in those cases. Toolkits have an explicit checkbox that can be enabled to allow for all builds to be within a build container.

Closing this issue, please re-open if you feel this doesn't answer your original question.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

XDanny322 picture XDanny322  路  3Comments

red8888 picture red8888  路  3Comments

dschu-lab picture dschu-lab  路  3Comments

terlar picture terlar  路  3Comments

drumadrian picture drumadrian  路  3Comments