aws-sam-cli - SAM Build 仅使用 --use-container 参数成功完成

标签 aws-sam-cli aws-sam

我正在开发一个用 python3.6 编写的 Lambda 函数以进行本地测试,然后在工作后部署到 AWS。为此,我正在使用 PyCharm 的 AWS Serverless Toolkit。

不包含 --use-container 时,SAM 构建无法成功构建范围。

当“使用容器”复选框被选中时,我可以构建该功能,但我真的不明白为什么没有这个复选框它就无法工作。

我的 requirements.txt文件如下:

sagemaker
boto3
pandas
s3fs
numpy
pathlib

带参数:
"C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd" build --template C:\Users\------\PycharmProjects\AutomatedSageMakerTraining\template.yaml --build-dir C:\Users\------\PycharmProjects\AutomatedSageMakerTraining\.aws-sam\build --use-container AutomatedSageMakerEvaluation
2019-08-20 09:23:29 Starting Build inside a container
2019-08-20 09:23:30 Building resource 'AutomatedSageMakerEvaluation'

Fetching lambci/lambda:build-python3.6 Docker container image......
2019-08-20 09:23:32 Mounting C:\Users\------\PycharmProjects\AutomatedSageMakerTraining as /tmp/samcli/source:ro,delegated inside runtime container

Build Succeeded

Built Artifacts  : ..\..\..\..\Users\------\PycharmProjects\AutomatedSageMakerTraining\.aws-sam\build
Built Template   : ..\..\..\..\Users\------\PycharmProjects\AutomatedSageMakerTraining\.aws-sam\build\template.yaml

Commands you can use next
=========================
[*] Invoke Function: sam local invoke -t ..\..\..\..\Users\------\PycharmProjects\AutomatedSageMakerTraining\.aws-sam\build\template.yaml
[*] Package: sam package --s3-bucket <yourbucket> --template-file ..\..\..\..\Users\------\PycharmProjects\AutomatedSageMakerTraining\.aws-sam\build\template.yaml

Running PythonPipBuilder:ResolveDependencies
Running PythonPipBuilder:CopySource

无参数:
"C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd" build --template C:\Users\------\PycharmProjects\AutomatedSageMakerTraining\template.yaml --build-dir C:\Users\------\PycharmProjects\AutomatedSageMakerTraining\.aws-sam\build AutomatedSageMakerEvaluation
2019-08-20 09:16:30 Building resource 'AutomatedSageMakerEvaluation'
2019-08-20 09:16:30 Running PythonPipBuilder:ResolveDependencies

Build Failed
Error: PythonPipBuilder:ResolveDependencies - {bcrypt==3.1.7(wheel), protobuf3-to-dict==0.1.5(sdist), fsspec==0.4.1(sdist), dockerpty==0.4.1(sdist), pycparser==2.19(sdist), texttable==0.9.1(sdist), pyyaml==3.13(wheel), cryptography==2.7(wheel), docopt==0.6.2(sdist), s3fs==0.3.3(sdist), pynacl==1.3.0(wheel), pywin32==224(wheel), pathlib==1.0.1(sdist), sagemaker==1.37.1(sdist)}

为了帮助调试此错误,我使用 --debug 参数运行了相同的命令:
"C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd" build --template C:\Users\------\PycharmProjects\AutomatedSageMakerTraining\template.yaml --build-dir C:\Users\------\PycharmProjects\AutomatedSageMakerTraining\.aws-sam\build AutomatedSageMakerEvaluation --debug
2019-08-20 09:30:14 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2019-08-20 09:30:14 Changing event name from before-call.apigateway to before-call.api-gateway
2019-08-20 09:30:14 Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2019-08-20 09:30:14 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2019-08-20 09:30:14 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-08-20 09:30:14 Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2019-08-20 09:30:14 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2019-08-20 09:30:14 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2019-08-20 09:30:14 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2019-08-20 09:30:14 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2019-08-20 09:30:14 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2019-08-20 09:30:14 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2019-08-20 09:30:14 Changing event name from before-call.apigateway to before-call.api-gateway
2019-08-20 09:30:14 Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2019-08-20 09:30:14 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2019-08-20 09:30:14 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-08-20 09:30:14 Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2019-08-20 09:30:14 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2019-08-20 09:30:14 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2019-08-20 09:30:14 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2019-08-20 09:30:14 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2019-08-20 09:30:14 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2019-08-20 09:30:14 Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2019-08-20 09:30:14 'build' command is called
2019-08-20 09:30:14 No Parameters detected in the template
2019-08-20 09:30:14 2 resources found in the template
2019-08-20 09:30:14 Found Serverless function with name='AutomatedSageMakerTraining' and CodeUri='.'
2019-08-20 09:30:14 Found Serverless function with name='AutomatedSageMakerEvaluation' and CodeUri='.'
2019-08-20 09:30:15 Building resource 'AutomatedSageMakerEvaluation'
2019-08-20 09:30:15 Loading workflow module 'aws_lambda_builders.workflows'
2019-08-20 09:30:15 Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2019-08-20 09:30:15 Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
2019-08-20 09:30:15 Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
2019-08-20 09:30:15 Registering workflow 'GoDepBuilder' with capability 'Capability(language='go', dependency_manager='dep', application_framework=None)'
2019-08-20 09:30:15 Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
2019-08-20 09:30:15 Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
2019-08-20 09:30:15 Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
2019-08-20 09:30:15 Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
2019-08-20 09:30:15 Found workflow 'PythonPipBuilder' to support capabilities 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2019-08-20 09:30:15 Running workflow 'PythonPipBuilder'
2019-08-20 09:30:15 Running PythonPipBuilder:ResolveDependencies
2019-08-20 09:30:15 calling pip download -r C:\Users\------\PycharmProjects\AutomatedSageMakerTraining\requirements.txt --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z
2019-08-20 09:31:20 Full dependency closure: {sagemaker==1.37.1(sdist), docker-pycreds==0.4.0(wheel), fsspec==0.4.1(sdist), setuptools==41.1.0(wheel), botocore==1.12.211(wheel), boto3==1.9.211(wheel), websocket-client==0.56.0(wheel), paramiko==2.6.0(wheel), docker==3.7.3(wheel), protobuf3-to-dict==0.1.5(sdist), scipy==1.3.1(wheel), cryptography==2.7(wheel), jmespath==0.9.4(wheel), six==1.12.0(wheel), pynacl==1.3.0(wheel), python-dateutil==2.8.0(wheel), docutils==0.15.2(wheel), chardet==3.0.4(wheel), docopt==0.6.2(sdist), requests==2.20.1(wheel), s3transfer==0.2.1(wheel), colorama==0.4.1(wheel), cached-property==1.5.1(wheel), asn1crypto==0.24.0(wheel), dockerpty==0.4.1(sdist), protobuf==3.9.1(wheel), jsonschema==2.6.0(wheel), pytz==2019.2(wheel), pywin32==224(wheel), certifi==2019.6.16(wheel), pyyaml==3.13(wheel), numpy==1.17.0(wheel), pycparser==2.19(sdist), idna==2.7(wheel), s3fs==0.3.3(sdist), pathlib==1.0.1(sdist), texttable==0.9.1(sdist), cffi==1.12.3(wheel), pypiwin32==223(wheel), pandas==0.25.0(wheel), urllib3==1.24.3(wheel), docker-compose==1.24.1(wheel), bcrypt==3.1.7(wheel)}
2019-08-20 09:31:20 initial compatible: {docker-pycreds==0.4.0(wheel), setuptools==41.1.0(wheel), botocore==1.12.211(wheel), boto3==1.9.211(wheel), websocket-client==0.56.0(wheel), paramiko==2.6.0(wheel), docker==3.7.3(wheel), jmespath==0.9.4(wheel), six==1.12.0(wheel), python-dateutil==2.8.0(wheel), chardet==3.0.4(wheel), docutils==0.15.2(wheel), requests==2.20.1(wheel), s3transfer==0.2.1(wheel), colorama==0.4.1(wheel), cached-property==1.5.1(wheel), asn1crypto==0.24.0(wheel), jsonschema==2.6.0(wheel), pytz==2019.2(wheel), certifi==2019.6.16(wheel), idna==2.7(wheel), pypiwin32==223(wheel), urllib3==1.24.3(wheel), docker-compose==1.24.1(wheel)}
2019-08-20 09:31:20 initial incompatible: {pyyaml==3.13(wheel), numpy==1.17.0(wheel), protobuf3-to-dict==0.1.5(sdist), scipy==1.3.1(wheel), pycparser==2.19(sdist), sagemaker==1.37.1(sdist), s3fs==0.3.3(sdist), pathlib==1.0.1(sdist), cryptography==2.7(wheel), fsspec==0.4.1(sdist), texttable==0.9.1(sdist), dockerpty==0.4.1(sdist), protobuf==3.9.1(wheel), cffi==1.12.3(wheel), pynacl==1.3.0(wheel), pandas==0.25.0(wheel), docopt==0.6.2(sdist), pywin32==224(wheel), bcrypt==3.1.7(wheel)}
2019-08-20 09:31:20 Downloading missing wheels: {pyyaml==3.13(wheel), numpy==1.17.0(wheel), protobuf3-to-dict==0.1.5(sdist), pycparser==2.19(sdist), scipy==1.3.1(wheel), sagemaker==1.37.1(sdist), s3fs==0.3.3(sdist), pathlib==1.0.1(sdist), cryptography==2.7(wheel), fsspec==0.4.1(sdist), texttable==0.9.1(sdist), dockerpty==0.4.1(sdist), protobuf==3.9.1(wheel), cffi==1.12.3(wheel), pynacl==1.3.0(wheel), pandas==0.25.0(wheel), docopt==0.6.2(sdist), pywin32==224(wheel), bcrypt==3.1.7(wheel)}
2019-08-20 09:31:20 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z pyyaml==3.13
2019-08-20 09:31:21 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z numpy==1.17.0
2019-08-20 09:31:27 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z protobuf3-to-dict==0.1.5
2019-08-20 09:31:28 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z pycparser==2.19
2019-08-20 09:31:29 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z scipy==1.3.1
2019-08-20 09:31:39 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z sagemaker==1.37.1
2019-08-20 09:31:40 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z s3fs==0.3.3
2019-08-20 09:31:41 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z pathlib==1.0.1
2019-08-20 09:31:42 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z cryptography==2.7
2019-08-20 09:31:44 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z fsspec==0.4.1
2019-08-20 09:31:45 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z texttable==0.9.1
2019-08-20 09:31:46 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z dockerpty==0.4.1
2019-08-20 09:31:47 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z protobuf==3.9.1
2019-08-20 09:31:49 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z cffi==1.12.3
2019-08-20 09:31:51 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z pynacl==1.3.0
2019-08-20 09:31:52 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z pandas==0.25.0
2019-08-20 09:32:01 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z docopt==0.6.2
2019-08-20 09:32:02 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\-------\AppData\Local\Temp\tmpnbl_t57z pywin32==224
2019-08-20 09:32:03 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp36m --dest C:\Users\------\AppData\Local\Temp\tmpnbl_t57z bcrypt==3.1.7
2019-08-20 09:32:04 compatible wheels after second download pass: {docker-pycreds==0.4.0(wheel), setuptools==41.1.0(wheel), botocore==1.12.211(wheel), boto3==1.9.211(wheel), websocket-client==0.56.0(wheel), paramiko==2.6.0(wheel), docker==3.7.3(wheel), scipy==1.3.1(wheel), jmespath==0.9.4(wheel), six==1.12.0(wheel), python-dateutil==2.8.0(wheel), docutils==0.15.2(wheel), chardet==3.0.4(wheel), requests==2.20.1(wheel), s3transfer==0.2.1(wheel), colorama==0.4.1(wheel), cached-property==1.5.1(wheel), asn1crypto==0.24.0(wheel), protobuf==3.9.1(wheel), jsonschema==2.6.0(wheel), pytz==2019.2(wheel), certifi==2019.6.16(wheel), numpy==1.17.0(wheel), idna==2.7(wheel), cffi==1.12.3(wheel), pypiwin32==223(wheel), pandas==0.25.0(wheel), urllib3==1.24.3(wheel), docker-compose==1.24.1(wheel)}
2019-08-20 09:32:04 Build missing wheels from sdists (C compiling True): {protobuf3-to-dict==0.1.5(sdist), pycparser==2.19(sdist), sagemaker==1.37.1(sdist), s3fs==0.3.3(sdist), pathlib==1.0.1(sdist), fsspec==0.4.1(sdist), texttable==0.9.1(sdist), dockerpty==0.4.1(sdist), docopt==0.6.2(sdist)}
2019-08-20 09:32:04 calling pip wheel --no-deps --wheel-dir C:\Users\-------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\protobuf3-to-dict-0.1.5.tar.gz
2019-08-20 09:32:07 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\pycparser-2.19.tar.gz
2019-08-20 09:32:10 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\sagemaker-1.37.1.tar.gz
2019-08-20 09:32:13 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\s3fs-0.3.3.tar.gz
2019-08-20 09:32:16 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\pathlib-1.0.1.tar.gz
2019-08-20 09:32:18 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\fsspec-0.4.1.tar.gz
2019-08-20 09:32:20 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\texttable-0.9.1.tar.gz
2019-08-20 09:32:23 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\dockerpty-0.4.1.tar.gz
2019-08-20 09:32:25 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\docopt-0.6.2.tar.gz
2019-08-20 09:32:28 compatible after building wheels (no C compiling): {docker-pycreds==0.4.0(wheel), setuptools==41.1.0(wheel), botocore==1.12.211(wheel), boto3==1.9.211(wheel), websocket-client==0.56.0(wheel), paramiko==2.6.0(wheel), docker==3.7.3(wheel), scipy==1.3.1(wheel), jmespath==0.9.4(wheel), six==1.12.0(wheel), python-dateutil==2.8.0(wheel), docutils==0.15.2(wheel), chardet==3.0.4(wheel), requests==2.20.1(wheel), s3transfer==0.2.1(wheel), colorama==0.4.1(wheel), cached-property==1.5.1(wheel), asn1crypto==0.24.0(wheel), protobuf==3.9.1(wheel), jsonschema==2.6.0(wheel), pytz==2019.2(wheel), certifi==2019.6.16(wheel), numpy==1.17.0(wheel), idna==2.7(wheel), cffi==1.12.3(wheel), pypiwin32==223(wheel), pandas==0.25.0(wheel), urllib3==1.24.3(wheel), docker-compose==1.24.1(wheel)}
2019-08-20 09:32:28 Build missing wheels from sdists (C compiling False): {protobuf3-to-dict==0.1.5(sdist), pycparser==2.19(sdist), sagemaker==1.37.1(sdist), s3fs==0.3.3(sdist), pathlib==1.0.1(sdist), fsspec==0.4.1(sdist), texttable==0.9.1(sdist), dockerpty==0.4.1(sdist), docopt==0.6.2(sdist)}
2019-08-20 09:32:28 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\protobuf3-to-dict-0.1.5.tar.gz
2019-08-20 09:32:28 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\pycparser-2.19.tar.gz
2019-08-20 09:32:28 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\sagemaker-1.37.1.tar.gz
2019-08-20 09:32:28 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\s3fs-0.3.3.tar.gz
2019-08-20 09:32:28 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\pathlib-1.0.1.tar.gz
2019-08-20 09:32:28 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\fsspec-0.4.1.tar.gz
2019-08-20 09:32:28 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\texttable-0.9.1.tar.gz
2019-08-20 09:32:28 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\dockerpty-0.4.1.tar.gz
2019-08-20 09:32:28 calling pip wheel --no-deps --wheel-dir C:\Users\------\AppData\Local\Temp\tmpnbl_t57z C:\Users\------\AppData\Local\Temp\tmpnbl_t57z\docopt-0.6.2.tar.gz
2019-08-20 09:32:28 compatible after building wheels (C compiling): {docker-pycreds==0.4.0(wheel), setuptools==41.1.0(wheel), botocore==1.12.211(wheel), boto3==1.9.211(wheel), websocket-client==0.56.0(wheel), paramiko==2.6.0(wheel), docker==3.7.3(wheel), scipy==1.3.1(wheel), jmespath==0.9.4(wheel), six==1.12.0(wheel), python-dateutil==2.8.0(wheel), docutils==0.15.2(wheel), chardet==3.0.4(wheel), requests==2.20.1(wheel), s3transfer==0.2.1(wheel), colorama==0.4.1(wheel), cached-property==1.5.1(wheel), asn1crypto==0.24.0(wheel), protobuf==3.9.1(wheel), jsonschema==2.6.0(wheel), pytz==2019.2(wheel), certifi==2019.6.16(wheel), numpy==1.17.0(wheel), idna==2.7(wheel), cffi==1.12.3(wheel), pypiwin32==223(wheel), pandas==0.25.0(wheel), urllib3==1.24.3(wheel), docker-compose==1.24.1(wheel)}
2019-08-20 09:32:28 Final compatible: {cached-property==1.5.1(wheel), docker-pycreds==0.4.0(wheel), asn1crypto==0.24.0(wheel), setuptools==41.1.0(wheel), protobuf==3.9.1(wheel), botocore==1.12.211(wheel), jsonschema==2.6.0(wheel), pytz==2019.2(wheel), boto3==1.9.211(wheel), certifi==2019.6.16(wheel), websocket-client==0.56.0(wheel), paramiko==2.6.0(wheel), urllib3==1.24.3(wheel), docker==3.7.3(wheel), numpy==1.17.0(wheel), scipy==1.3.1(wheel), idna==2.7(wheel), chardet==3.0.4(wheel), jmespath==0.9.4(wheel), six==1.12.0(wheel), cffi==1.12.3(wheel), pypiwin32==223(wheel), python-dateutil==2.8.0(wheel), docutils==0.15.2(wheel), requests==2.20.1(wheel), pandas==0.25.0(wheel), docker-compose==1.24.1(wheel), s3transfer==0.2.1(wheel), colorama==0.4.1(wheel)}
2019-08-20 09:32:28 Final incompatible: {pyyaml==3.13(wheel), numpy==1.17.0(wheel), scipy==1.3.1(wheel), cryptography==2.7(wheel), protobuf==3.9.1(wheel), cffi==1.12.3(wheel), pynacl==1.3.0(wheel), pandas==0.25.0(wheel), pywin32==224(wheel), bcrypt==3.1.7(wheel)}
2019-08-20 09:32:28 Final missing wheels: {pyyaml==3.13(wheel), protobuf3-to-dict==0.1.5(sdist), pycparser==2.19(sdist), sagemaker==1.37.1(sdist), s3fs==0.3.3(sdist), pathlib==1.0.1(sdist), cryptography==2.7(wheel), fsspec==0.4.1(sdist), texttable==0.9.1(sdist), dockerpty==0.4.1(sdist), pynacl==1.3.0(wheel), docopt==0.6.2(sdist), pywin32==224(wheel), bcrypt==3.1.7(wheel)}
2019-08-20 09:32:55 PythonPipBuilder:ResolveDependencies failed
Traceback (most recent call last):
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\python_pip\actions.py", line 39, in execute
    self.scratch_dir
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\python_pip\packager.py", line 143, in build_dependencies
    requirements_path, artifacts_dir_path, scratch_dir_path)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\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: {pyyaml==3.13(wheel), protobuf3-to-dict==0.1.5(sdist), pycparser==2.19(sdist), sagemaker==1.37.1(sdist), s3fs==0.3.3(sdist), pathlib==1.0.1(sdist), cryptography==2.7(wheel), fsspec==0.4.1(sdist), texttable==0.9.1(sdist), dockerpty==0.4.1(sdist), pynacl==1.3.0(wheel), docopt==0.6.2(sdist), pywin32==224(wheel), bcrypt==3.1.7(wheel)}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflow.py", line 248, in run
    action.execute()
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\python_pip\actions.py", line 42, in execute
    raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: {pyyaml==3.13(wheel), protobuf3-to-dict==0.1.5(sdist), pycparser==2.19(sdist), sagemaker==1.37.1(sdist), s3fs==0.3.3(sdist), pathlib==1.0.1(sdist), cryptography==2.7(wheel), fsspec==0.4.1(sdist), texttable==0.9.1(sdist), dockerpty==0.4.1(sdist), pynacl==1.3.0(wheel), docopt==0.6.2(sdist), pywin32==224(wheel), bcrypt==3.1.7(wheel)}

Build Failed
2019-08-20 09:32:55 Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 160781, 'exitReason': 'UserException', 'exitCode': 1, 'requestId': '943b9308-c11b-43e0-9d6d-5bbc984946ad', 'installationId': '0c5d4463-668a-4706-ae40-afd0704d66bd', 'sessionId': '4736e025-2966-4a4b-aeb6-2702fe347779', 'executionEnvironment': 'CLI', 'pyversion': '3.6.7', 'samcliVersion': '0.19.0'}}]}
2019-08-20 09:32:55 Starting new HTTPS connection (1): aws-serverless-tools-telemetry.us-west-2.amazonaws.com:443
2019-08-20 09:32:56 HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: PythonPipBuilder:ResolveDependencies - {pyyaml==3.13(wheel), protobuf3-to-dict==0.1.5(sdist), pycparser==2.19(sdist), sagemaker==1.37.1(sdist), s3fs==0.3.3(sdist), pathlib==1.0.1(sdist), cryptography==2.7(wheel), fsspec==0.4.1(sdist), texttable==0.9.1(sdist), dockerpty==0.4.1(sdist), pynacl==1.3.0(wheel), docopt==0.6.2(sdist), pywin32==224(wheel), bcrypt==3.1.7(wheel)}

当 --use-container 参数未设置时,似乎由于某种原因它无法解析兼容的依赖项。

幸运的是,通过将 template.yaml 部署为无服务器(CloudFormation)应用程序,我能够将 Lambda 函数部署到容器内的 AWS,如果我不选中此框,它也会失败。 Right click template.yaml Select build function inside a container

最佳答案

我没有解释为什么这适用于 --use-container ,但我遇到了同样的问题,似乎没有其他人回答这个问题。
您尝试使用的某些库似乎缺少轮文件。它实际上在调试消息中是这样说的,但是如果您不知道要查找的内容,则不容易找到。更多关于车轮的信息,请访问 https://pythonwheels.com/ .
因此,经过几个小时的挖掘,我在终端中运行了以下命令:

pip install wheel
之后,我可以在没有 --use-container 的情况下在本地构建、调用该函数并部署到 AWS。范围。

关于aws-sam-cli - SAM Build 仅使用 --use-container 参数成功完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57569718/

相关文章:

aws-lambda - 如何在没有内联代码的情况下使用 lambda 函数部署 cloudformation?

aws-lambda - 从另一个嵌套堆栈引用 lambda 函数 Arn

aws-lambda - 为什么sam包每次都会上传工件?

amazon-web-services - 尝试在本地访问 DynamoDB 时超时

amazon-web-services - 如何调用也在 AWS SAM 模板中定义的另一个 lambda 函数?

amazon-web-services - 引用 SAM 模板 (YAML) 中的元数据

aws-cloudformation - 控制 SAM 功能日志组创建

amazon-web-services - 在定义单个 AWS::Serverless::Function 的 SAM 模板中指定多个 API 阶段和 Lambda 别名

python - 如何在部署 lambda 函数之前删除 ptvsd 调试代码