question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sam build fails when using pyjwt[crypto] in requirements.txt

See original GitHub issue

Description

If I include pyjwt[crypto] in the requiements.txt file, I get an error that says:

`(.venv) PS C:\Users\jwh> sam build --use-container Starting Build inside a container Building resource ‘AuthorizerFunction’ Failed to download a new lambci/lambda:build-python3.7 image. Invoking with the already downloaded image. Mounting C:\Users\jwh\apiauthexternal as /tmp/samcli/source:ro,delegated inside runtime container

Build Failed Error: PythonPipBuilder:ResolveDependencies - {cryptography==2.8(wheel)} Running PythonPipBuilder:ResolveDependencies`

Also fails w/o --use-container but with slightly different error:

Error: PythonPipBuilder:ResolveDependencies - {cryptography==2.8(wheel), pycparser==2.19(sdist)}

Note that I am running on Windows 10 platform here.

Steps to reproduce

  1. Create a Python Lambda project
  2. Add pyjwt[crypto] to requirements.txt
  3. sam build --use-container or sam build

Observed result

`sam build --use-container --debug Using SAM Template at C:\Users\jwh\aws\template.yaml Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics ‘build’ command is called Starting Build inside a container Collected default values for parameters: {‘StackUpdateComment’: ‘V1.1’, ‘AutoPublishAlias’: ‘dev’, ‘LineOfBusiness’: ‘cc’, ‘ExecutionEnvironment’: ‘dev’, ‘LogLevel’: ‘DEBUG’, ‘PrefixParameter’: ‘-001-s-031-e1-00-dev-’, ‘LambdaName’: ‘encore-api-internal-authorizer’} Unable to resolve property ManagedPolicyArns: [{‘Ref’: ‘LambdaPolicyDocument’}, {‘Fn::ImportValue’: ‘PolicyKMS’}]. Leaving as is. Unable to resolve property Events: None. Leaving as is. 4 resources found in the template Found Serverless function with name=‘AuthorizerFunction’ and CodeUri=‘apiauthexternal/’ Building resource ‘AuthorizerFunction’ Failed to download image with name lambci/lambda:build-python3.7 Failed to download a new lambci/lambda:build-python3.7 image. Invoking with the already downloaded image. Mounting C:\Users\jwh\apiauthexternal as /tmp/samcli/source:ro,delegated inside runtime container Using the request object from command line argument Loading workflow module ‘aws_lambda_builders.workflows’ Registering workflow ‘PythonPipBuilder’ with capability ‘Capability(language=‘python’, dependency_manager=‘pip’, application_framework=None)’ Registering workflow ‘NodejsNpmBuilder’ with capability ‘Capability(language=‘nodejs’, dependency_manager=‘npm’, application_framework=None)’ Registering workflow ‘RubyBundlerBuilder’ with capability ‘Capability(language=‘ruby’, dependency_manager=‘bundler’, application_framework=None)’ Registering workflow ‘GoDepBuilder’ with capability ‘Capability(language=‘go’, dependency_manager=‘dep’, application_framework=None)’ Registering workflow ‘GoModulesBuilder’ with capability ‘Capability(language=‘go’, dependency_manager=‘modules’, application_framework=None)’ Registering workflow ‘JavaGradleWorkflow’ with capability ‘Capability(language=‘java’, dependency_manager=‘gradle’, application_framework=None)’ Registering workflow ‘JavaMavenWorkflow’ with capability ‘Capability(language=‘java’, dependency_manager=‘maven’, application_framework=None)’ Registering workflow ‘DotnetCliPackageBuilder’ with capability ‘Capability(language=‘dotnet’, dependency_manager=‘cli-package’, application_framework=None)’ Found workflow ‘PythonPipBuilder’ to support capabilities ‘Capability(language=‘python’, dependency_manager=‘pip’, application_framework=None)’ Running workflow ‘PythonPipBuilder’ Running PythonPipBuilder:ResolveDependencies calling pip download -r /tmp/samcli/source/requirements.txt --dest /tmp/samcli/scratch Full dependency closure: {cffi==1.13.2(wheel), pyjwt==1.7.1(wheel), pycparser==2.19(sdist), cryptography==2.8(wheel), six==1.12.0(wheel)} initial compatible: {cffi==1.13.2(wheel), pyjwt==1.7.1(wheel), six==1.12.0(wheel)} initial incompatible: {pycparser==2.19(sdist), cryptography==2.8(wheel)} Downloading missing wheels: {pycparser==2.19(sdist), cryptography==2.8(wheel)} calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp37m --dest /tmp/samcli/scratch pycparser==2.19 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp37m --dest /tmp/samcli/scratch cryptography==2.8 compatible wheels after second download pass: {cffi==1.13.2(wheel), pyjwt==1.7.1(wheel), six==1.12.0(wheel)} Build missing wheels from sdists (C compiling True): {pycparser==2.19(sdist)} calling pip wheel --no-deps --wheel-dir /tmp/samcli/scratch /tmp/samcli/scratch/pycparser-2.19.tar.gz compatible after building wheels (no C compiling): {cffi==1.13.2(wheel), pycparser==2.19(wheel), pyjwt==1.7.1(wheel), six==1.12.0(wheel)} Build missing wheels from sdists (C compiling False): set() compatible after building wheels (C compiling): {cffi==1.13.2(wheel), pycparser==2.19(wheel), pyjwt==1.7.1(wheel), six==1.12.0(wheel)} Final compatible: {cffi==1.13.2(wheel), pycparser==2.19(wheel), pyjwt==1.7.1(wheel), six==1.12.0(wheel)} Final incompatible: {cryptography==2.8(wheel)} Final missing wheels: {cryptography==2.8(wheel)} PythonPipBuilder:ResolveDependencies failed Traceback (most recent call last): File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/actions.py”, line 39, in execute requirements_path=self.manifest_path File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/packager.py”, line 143, in build_dependencies requirements_path, artifacts_dir_path, scratch_dir_path) File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/packager.py”, line 212, in build_site_packages raise MissingDependencyError(packages_without_wheels) aws_lambda_builders.workflows.python_pip.packager.MissingDependencyError: {cryptography==2.8(wheel)}

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflow.py”, line 248, in run action.execute() File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/actions.py”, line 42, in execute raise ActionFailedError(str(ex)) aws_lambda_builders.actions.ActionFailedError: {cryptography==2.8(wheel)} Builder workflow failed Traceback (most recent call last): File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/actions.py”, line 39, in execute requirements_path=self.manifest_path File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/packager.py”, line 143, in build_dependencies requirements_path, artifacts_dir_path, scratch_dir_path) File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/packager.py”, line 212, in build_site_packages raise MissingDependencyError(packages_without_wheels) aws_lambda_builders.workflows.python_pip.packager.MissingDependencyError: {cryptography==2.8(wheel)}

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflow.py”, line 248, in run action.execute() File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/actions.py”, line 42, in execute raise ActionFailedError(str(ex)) aws_lambda_builders.actions.ActionFailedError: {cryptography==2.8(wheel)}

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/main.py”, line 137, in main mode=params.get(‘mode’, None)) File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/builder.py”, line 115, in build return workflow.run() File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflow.py”, line 65, in wrapper func(self, *args, **kwargs) File “/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflow.py”, line 257, in run reason=str(ex)) aws_lambda_builders.exceptions.WorkflowFailedError: PythonPipBuilder:ResolveDependencies - {cryptography==2.8(wheel)} Build inside container returned response {“jsonrpc”: “2.0”, “id”: 1, “error”: {“code”: 400, “message”: “PythonPipBuilder:ResolveDependencies - {cryptography==2.8(wheel)}”}}

Build Failed Sending Telemetry: {‘metrics’: [{‘commandRun’: {‘awsProfileProvided’: False, ‘debugFlagProvided’: True, ‘region’: ‘’, ‘commandName’: ‘sam build’, ‘duration’: 26196, ‘exitReason’: ‘UserException’, ‘exitCode’: 1, ‘requestId’: ‘d21ab057-cbdc-42ef-9235-3aad41033971’, ‘installationId’: ‘93177b47-57bd-4b5b-9211-97cbbf2cefe2’, ‘sessionId’: ‘e5484581-086e-43bf-9834-92c7be077d75’, ‘executionEnvironment’: ‘CLI’, ‘pyversion’: ‘3.6.7’, ‘samcliVersion’: ‘0.30.0’}}]} HTTPSConnectionPool(host=‘aws-serverless-tools-telemetry.us-west-2.amazonaws.com’, port=443): Read timed out. (read timeout=0.1) Error: PythonPipBuilder:ResolveDependencies - {cryptography==2.8(wheel)}`

Expected result

Successful build

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Windows 10
  2. sam --version: SAM CLI, version 0.30.0

Add --debug flag to command you are running

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
josephhanceslmcommented, Nov 11, 2019

I specifically pulled the latest Docker image. I did see that earlier issue and it seems similar but not exactly the same. FWIW, I found that I could work around this issue by creating my own Docker image, installing parakmiko in that image, re-tagging the image as:

lambci/lambda:build-python3.7

Here is the Dockerfile I’m using:

FROM lambci/lambda:build-python3.7 RUN pip install paramiko

After this tag the new image with lambci/lambda:build-python3.7 docker tag <image_id> lambci/lambda:build-python3.7 So that ‘sam build --use-container’ will use the modified image

This works perfectly but if I leave out the paramiko install, it fails every time.

0reactions
iongioncommented, Jul 22, 2021

@dmitry-weirdo I have exactly the same issue, trying to avoid the use-container overhead

What wheel version do you use ? What cryptography version ?

2021-07-22 17:24:47,411 | initial incompatible: {cffi==1.14.6(sdist), cryptography==3.3.2(sdist), pyrsistent==0.18.0(sdist)}
2021-07-22 17:24:47,411 | Downloading missing wheels: {cffi==1.14.6(sdist), cryptography==3.3.2(sdist), pyrsistent==0.18.0(sdist)}
2021-07-22 17:24:47,412 | calling pip download --only-binary=:all: --no-deps --platform manylinux2014_x86_64 --implementation cp --abi cp36m --dest /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd cffi==1.14.6
2021-07-22 17:24:48,577 | calling pip download --only-binary=:all: --no-deps --platform manylinux2014_x86_64 --implementation cp --abi cp36m --dest /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd cryptography==3.3.2
2021-07-22 17:24:49,891 | calling pip download --only-binary=:all: --no-deps --platform manylinux2014_x86_64 --implementation cp --abi cp36m --dest /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd pyrsistent==0.18.0
2021-07-22 17:24:50,893 | compatible wheels after second download pass: {protobuf==3.15.8(wheel), pyjwt==2.1.0(wheel), pip-tools==6.2.0(wheel), python-dateutil==2.8.2(wheel), pip==21.1.3(wheel), urllib3==1.26.6(wheel), attrs==21.2.0(wheel), botocore==1.21.4(wheel), s3transfer==0.5.0(wheel), charset-normalizer==2.0.3(wheel), jmespath==0.10.0(wheel), pep517==0.11.0(wheel), idna==3.2(wheel), six==1.16.0(wheel), click==8.0.1(wheel), boto3==1.18.4(wheel), zipp==3.5.0(wheel), wheel==0.36.2(wheel), importlib-metadata==4.6.1(wheel), mysql-connector-python==8.0.26(wheel), pycparser==2.20(wheel), typing-extensions==3.10.0.0(wheel), setuptools==57.4.0(wheel), certifi==2021.5.30(wheel), jsonschema==3.2.0(wheel), tomli==1.0.4(wheel), requests==2.26.0(wheel), redis==3.5.3(wheel)}
2021-07-22 17:24:50,893 | Build missing wheels from sdists (C compiling True): {cffi==1.14.6(sdist), cryptography==3.3.2(sdist), pyrsistent==0.18.0(sdist)}
2021-07-22 17:24:50,893 | calling pip wheel --no-deps --wheel-dir /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd/cffi-1.14.6.tar.gz
2021-07-22 17:24:54,219 | calling pip wheel --no-deps --wheel-dir /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd/cryptography-3.3.2.tar.gz
2021-07-22 17:25:35,675 | calling pip wheel --no-deps --wheel-dir /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd/pyrsistent-0.18.0.tar.gz
2021-07-22 17:25:40,935 | compatible after building wheels (no C compiling): {protobuf==3.15.8(wheel), pyjwt==2.1.0(wheel), pip-tools==6.2.0(wheel), python-dateutil==2.8.2(wheel), pip==21.1.3(wheel), urllib3==1.26.6(wheel), attrs==21.2.0(wheel), botocore==1.21.4(wheel), s3transfer==0.5.0(wheel), charset-normalizer==2.0.3(wheel), jmespath==0.10.0(wheel), pep517==0.11.0(wheel), idna==3.2(wheel), six==1.16.0(wheel), click==8.0.1(wheel), boto3==1.18.4(wheel), zipp==3.5.0(wheel), wheel==0.36.2(wheel), importlib-metadata==4.6.1(wheel), mysql-connector-python==8.0.26(wheel), pycparser==2.20(wheel), typing-extensions==3.10.0.0(wheel), setuptools==57.4.0(wheel), certifi==2021.5.30(wheel), jsonschema==3.2.0(wheel), tomli==1.0.4(wheel), requests==2.26.0(wheel), redis==3.5.3(wheel)}
2021-07-22 17:25:40,935 | Build missing wheels from sdists (C compiling False): {cffi==1.14.6(sdist), cryptography==3.3.2(sdist), pyrsistent==0.18.0(sdist)}
2021-07-22 17:25:40,936 | calling pip wheel --no-deps --wheel-dir /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd/cffi-1.14.6.tar.gz
2021-07-22 17:25:43,491 | calling pip wheel --no-deps --wheel-dir /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd/cryptography-3.3.2.tar.gz
2021-07-22 17:25:48,731 | calling pip wheel --no-deps --wheel-dir /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd /var/folders/4j/26zwjrzn1ygdpt4803gynxkr0000gn/T/tmp2rkxi6vd/pyrsistent-0.18.0.tar.gz
2021-07-22 17:25:52,992 | compatible after building wheels (C compiling): {protobuf==3.15.8(wheel), pyjwt==2.1.0(wheel), pip-tools==6.2.0(wheel), python-dateutil==2.8.2(wheel), pip==21.1.3(wheel), urllib3==1.26.6(wheel), attrs==21.2.0(wheel), botocore==1.21.4(wheel), s3transfer==0.5.0(wheel), charset-normalizer==2.0.3(wheel), jmespath==0.10.0(wheel), pep517==0.11.0(wheel), idna==3.2(wheel), six==1.16.0(wheel), click==8.0.1(wheel), boto3==1.18.4(wheel), zipp==3.5.0(wheel), wheel==0.36.2(wheel), importlib-metadata==4.6.1(wheel), mysql-connector-python==8.0.26(wheel), pycparser==2.20(wheel), typing-extensions==3.10.0.0(wheel), setuptools==57.4.0(wheel), certifi==2021.5.30(wheel), jsonschema==3.2.0(wheel), tomli==1.0.4(wheel), requests==2.26.0(wheel), redis==3.5.3(wheel)}
2021-07-22 17:25:52,992 | Final compatible: {boto3==1.18.4(wheel), protobuf==3.15.8(wheel), zipp==3.5.0(wheel), wheel==0.36.2(wheel), importlib-metadata==4.6.1(wheel), pyjwt==2.1.0(wheel), pip-tools==6.2.0(wheel), python-dateutil==2.8.2(wheel), mysql-connector-python==8.0.26(wheel), pip==21.1.3(wheel), pycparser==2.20(wheel), typing-extensions==3.10.0.0(wheel), six==1.16.0(wheel), urllib3==1.26.6(wheel), setuptools==57.4.0(wheel), certifi==2021.5.30(wheel), jsonschema==3.2.0(wheel), attrs==21.2.0(wheel), redis==3.5.3(wheel), botocore==1.21.4(wheel), s3transfer==0.5.0(wheel), charset-normalizer==2.0.3(wheel), tomli==1.0.4(wheel), jmespath==0.10.0(wheel), requests==2.26.0(wheel), pep517==0.11.0(wheel), idna==3.2(wheel), click==8.0.1(wheel)}
2021-07-22 17:25:52,992 | Final incompatible: {cryptography==3.3.2(wheel), pyrsistent==0.18.0(wheel)}
2021-07-22 17:25:52,993 | Final missing wheels: {cffi==1.14.6(sdist), cryptography==3.3.2(sdist), pyrsistent==0.18.0(sdist)}
2021-07-22 17:25:55,355 | PythonPipBuilder:ResolveDependencies failed
Traceback (most recent call last):
  File "/usr/local/Cellar/aws-sam-cli/1.27.2/libexec/lib/python3.8/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 39, in execute
    package_builder.build_dependencies(
  File "/usr/local/Cellar/aws-sam-cli/1.27.2/libexec/lib/python3.8/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 139, in build_dependencies
    self._dependency_builder.build_site_packages(requirements_path, artifacts_dir_path, scratch_dir_path)
  File "/usr/local/Cellar/aws-sam-cli/1.27.2/libexec/lib/python3.8/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 219, in build_site_packages
    raise MissingDependencyError(packages_without_wheels)
aws_lambda_builders.workflows.python_pip.packager.MissingDependencyError: {cffi==1.14.6(sdist), cryptography==3.3.2(sdist), pyrsistent==0.18.0(sdist)}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/aws-sam-cli/1.27.2/libexec/lib/python3.8/site-packages/aws_lambda_builders/workflow.py", line 269, in run
    action.execute()
  File "/usr/local/Cellar/aws-sam-cli/1.27.2/libexec/lib/python3.8/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 45, in execute
    raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: {cffi==1.14.6(sdist), cryptography==3.3.2(sdist), pyrsistent==0.18.0(sdist)}

Build Failed
2021-07-22 17:25:55,376 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': 'e1324d97-688e-4c28-b2b6-fea2dd995859', 'installationId': '46c1c09b-6054-426a-9d7a-8ff7852e821c', 'sessionId': '7612026d-9b04-4019-b9c5-f6c7c923d6e4', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.11', 'samcliVersion': '1.27.2', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 139743, 'exitReason': 'WorkflowFailedError', 'exitCode': 1}}]}
2021-07-22 17:25:56,389 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: PythonPipBuilder:ResolveDependencies - {cffi==1.14.6(sdist), cryptography==3.3.2(sdist), pyrsistent==0.18.0(sdist)}
Read more comments on GitHub >

github_iconTop Results From Across the Web

sam build fails when using pyjwt[crypto] in requirements.txt
Invoking with the already downloaded image. Mounting C:\Users\jwh\apiauthexternal as /tmp/samcli/source:ro,delegated inside runtime container.
Read more >
aws sam build not able to build packages which require ...
I have, but it throws a different error saying that it can't find the requirements.txt file. I also tried with the -m argument...
Read more >
python - Bryson Tyrrell - WordPress.com
You can now use the sam build command to compile deployment packages for AWS Lambda functions written in Python using the AWS Serverless ......
Read more >
Tutorial: Deploying a Hello World application
In this guide, you download, build, and deploy a sample Hello World application using AWS SAM. You then test the application in the...
Read more >
Package List — Spack 0.20.0.dev0 documentation
This is a list of things you can install using Spack. It is automatically generated based on the packages in this Spack version....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found