我正在尝试在要上传的Lambda中使用sqlalchemy库。这将使用通过Pycharm中的AWS工具箱创建的AWS Lambda项目。 sqlalchemy库仅用于将pandas表插入到mysql中(表具有300多个列,将来还会添加更多列,因此,显式定义列名不是一种选择)。请注意,该库包含在requirements.txt文件中。 使用运行配置内的“容器内的构建功能”参数在本地计算机上运行时,lambda运行良好。我相信此参数等效于使用命令:
sam build --use-container
但是,用于远程部署lambda的配置不包含参数“容器内部的构建功能”。这样,当我尝试远程部署我的功能时,会出现以下错误:
2019-04-17 13:23:07 Using SAM Template at /Users/davidpell/PycharmProjects/lambda/template.yaml
2019-04-17 13:23:07 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2019-04-17 13:23:07 Changing event name from before-call.apigateway to before-call.api-gateway
2019-04-17 13:23:07 Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2019-04-17 13:23:07 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2019-04-17 13:23:07 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-04-17 13:23:07 Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2019-04-17 13:23:07 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2019-04-17 13:23:07 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2019-04-17 13:23:07 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2019-04-17 13:23:07 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2019-04-17 13:23:07 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2019-04-17 13:23:07 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2019-04-17 13:23:07 Changing event name from before-call.apigateway to before-call.api-gateway
2019-04-17 13:23:07 Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2019-04-17 13:23:07 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2019-04-17 13:23:07 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-04-17 13:23:07 Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2019-04-17 13:23:07 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2019-04-17 13:23:07 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2019-04-17 13:23:07 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2019-04-17 13:23:07 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2019-04-17 13:23:07 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2019-04-17 13:23:07 'build' command is called
2019-04-17 13:23:07 No Parameters detected in the template
2019-04-17 13:23:07 2 resources found in the template
2019-04-17 13:23:07 Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/'
2019-04-17 13:23:08 Building resource 'HelloWorldFunction'
2019-04-17 13:23:08 Loading workflow module 'aws_lambda_builders.workflows'
2019-04-17 13:23:08 Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2019-04-17 13:23:08 Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
2019-04-17 13:23:08 Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
2019-04-17 13:23:08 Registering workflow 'GoDepBuilder' with capability 'Capability(language='go', dependency_manager='dep', application_framework=None)'
2019-04-17 13:23:08 Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
2019-04-17 13:23:08 Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
2019-04-17 13:23:08 Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
2019-04-17 13:23:08 Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
2019-04-17 13:23:08 Found workflow 'PythonPipBuilder' to support capabilities 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2019-04-17 13:23:08 Running workflow 'PythonPipBuilder'
2019-04-17 13:23:08 Running PythonPipBuilder:ResolveDependencies
2019-04-17 13:23:08 calling pip download -r /Users/davidpell/PycharmProjects/lambda/hello_world/requirements.txt --dest /var/folders/c4/jqqz7trx02l9w1qkbx8dzxvr0000gn/T/tmpgl5r1tqp
2019-04-17 13:23:13 Full dependency closure: {numpy==1.16.2(wheel), six==1.12.0(wheel), requests==2.21.0(wheel), pytz==2019.1(wheel), pymysql==0.9.3(wheel), urllib3==1.24.1(wheel), python-dateutil==2.8.0(wheel), setuptools==41.0.0(wheel), sqlalchemy==1.3.3(sdist), pip==19.0.3(wheel), idna==2.8(wheel), chardet==3.0.4(wheel), certifi==2019.3.9(wheel), pandas==0.24.2(wheel)}
2019-04-17 13:23:13 initial compatible: {six==1.12.0(wheel), requests==2.21.0(wheel), pytz==2019.1(wheel), pymysql==0.9.3(wheel), urllib3==1.24.1(wheel), python-dateutil==2.8.0(wheel), setuptools==41.0.0(wheel), pip==19.0.3(wheel), idna==2.8(wheel), chardet==3.0.4(wheel), certifi==2019.3.9(wheel)}
2019-04-17 13:23:13 initial incompatible: {numpy==1.16.2(wheel), pandas==0.24.2(wheel), sqlalchemy==1.3.3(sdist)}
2019-04-17 13:23:13 Downloading missing wheels: {sqlalchemy==1.3.3(sdist), numpy==1.16.2(wheel), pandas==0.24.2(wheel)}
2019-04-17 13:23:13 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp37m --dest /var/folders/c4/jqqz7trx02l9w1qkbx8dzxvr0000gn/T/tmpgl5r1tqp sqlalchemy==1.3.3
2019-04-17 13:23:14 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp37m --dest /var/folders/c4/jqqz7trx02l9w1qkbx8dzxvr0000gn/T/tmpgl5r1tqp numpy==1.16.2
2019-04-17 13:23:15 calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp37m --dest /var/folders/c4/jqqz7trx02l9w1qkbx8dzxvr0000gn/T/tmpgl5r1tqp pandas==0.24.2
2019-04-17 13:23:16 compatible wheels after second download pass: {numpy==1.16.2(wheel), six==1.12.0(wheel), requests==2.21.0(wheel), pytz==2019.1(wheel), pymysql==0.9.3(wheel), urllib3==1.24.1(wheel), python-dateutil==2.8.0(wheel), setuptools==41.0.0(wheel), pip==19.0.3(wheel), idna==2.8(wheel), chardet==3.0.4(wheel), certifi==2019.3.9(wheel), pandas==0.24.2(wheel)}
2019-04-17 13:23:16 Build missing wheels from sdists (C compiling True): {sqlalchemy==1.3.3(sdist)}
2019-04-17 13:23:16 calling pip wheel --no-deps --wheel-dir /var/folders/c4/jqqz7trx02l9w1qkbx8dzxvr0000gn/T/tmpgl5r1tqp /var/folders/c4/jqqz7trx02l9w1qkbx8dzxvr0000gn/T/tmpgl5r1tqp/SQLAlchemy-1.3.3.tar.gz
2019-04-17 13:23:17 compatible after building wheels (no C compiling): {numpy==1.16.2(wheel), six==1.12.0(wheel), requests==2.21.0(wheel), pytz==2019.1(wheel), pymysql==0.9.3(wheel), urllib3==1.24.1(wheel), python-dateutil==2.8.0(wheel), setuptools==41.0.0(wheel), pip==19.0.3(wheel), idna==2.8(wheel), chardet==3.0.4(wheel), certifi==2019.3.9(wheel), pandas==0.24.2(wheel)}
2019-04-17 13:23:17 Build missing wheels from sdists (C compiling False): {sqlalchemy==1.3.3(sdist)}
2019-04-17 13:23:17 calling pip wheel --no-deps --wheel-dir /var/folders/c4/jqqz7trx02l9w1qkbx8dzxvr0000gn/T/tmpgl5r1tqp /var/folders/c4/jqqz7trx02l9w1qkbx8dzxvr0000gn/T/tmpgl5r1tqp/SQLAlchemy-1.3.3.tar.gz
2019-04-17 13:23:19 compatible after building wheels (C compiling): {numpy==1.16.2(wheel), six==1.12.0(wheel), requests==2.21.0(wheel), pytz==2019.1(wheel), pymysql==0.9.3(wheel), urllib3==1.24.1(wheel), python-dateutil==2.8.0(wheel), setuptools==41.0.0(wheel), pip==19.0.3(wheel), idna==2.8(wheel), chardet==3.0.4(wheel), certifi==2019.3.9(wheel), pandas==0.24.2(wheel)}
2019-04-17 13:23:19 Final compatible: {numpy==1.16.2(wheel), six==1.12.0(wheel), requests==2.21.0(wheel), pytz==2019.1(wheel), pymysql==0.9.3(wheel), urllib3==1.24.1(wheel), python-dateutil==2.8.0(wheel), setuptools==41.0.0(wheel), pip==19.0.3(wheel), idna==2.8(wheel), chardet==3.0.4(wheel), certifi==2019.3.9(wheel), pandas==0.24.2(wheel)}
2019-04-17 13:23:19 Final incompatible: {numpy==1.16.2(wheel), pandas==0.24.2(wheel)}
2019-04-17 13:23:19 Final missing wheels: {sqlalchemy==1.3.3(sdist)}
2019-04-17 13:23:20 PythonPipBuilder:ResolveDependencies failed
Traceback (most recent call last):
File "/usr/local/Cellar/aws-sam-cli/0.14.2/libexec/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 39, in execute
self.scratch_dir
File "/usr/local/Cellar/aws-sam-cli/0.14.2/libexec/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 "/usr/local/Cellar/aws-sam-cli/0.14.2/libexec/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: {sqlalchemy==1.3.3(sdist)}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/Cellar/aws-sam-cli/0.14.2/libexec/lib/python3.7/site-packages/aws_lambda_builders/workflow.py", line 236, in run
action.execute()
File "/usr/local/Cellar/aws-sam-cli/0.14.2/libexec/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: {sqlalchemy==1.3.3(sdist)}
Build Failed
Error: PythonPipBuilder:ResolveDependencies - {sqlalchemy==1.3.3(sdist)}
兴趣点是
calling pip download --only-binary=:all: --no-deps --platform manylinux1_x86_64 --implementation cp --abi cp37m --dest /var/folders/c4/jqqz7trx02l9w1qkbx8dzxvr0000gn/T/tmpgl5r1tqp sqlalchemy==1.3.3
删除参数--only-binary=:all:
将允许此单个命令起作用,但是我不知道这是否有帮助。
如何构建包含sqlalchemy依赖项的lambda函数?