首页 > 解决方案 > “lambda_function”:没有名为“ask_sdk_core”的模块

问题描述

希望你一切顺利 :)

我 pip 将所有外部库安装到一个文件夹中。压缩安装的库。将其上传到 lambda 的图层。但是,我最终遇到了这样的错误。有谁知道为什么?让我知道是否有任何其他有用的信息可供我提供。在此处输入图像描述

这是已安装库的目录树视图:

├───ask_sdk_core
│   ├───dispatch_components
│   │   └───__pycache__
│   ├───utils
│   │   └───__pycache__
│   ├───view_resolvers
│   │   └───__pycache__
│   └───__pycache__
├───ask_sdk_core-1.14.0.dist-info
├───ask_sdk_model
│   ├───canfulfill
│   │   └───__pycache__
│   ├───dialog
│   │   └───__pycache__
│   ├───dynamic_endpoints
│   │   └───__pycache__
│   ├───er
│   │   ├───dynamic
│   │   │   └───__pycache__
│   │   └───__pycache__
│   ├───events
│   │   ├───skillevents
│   │   │   └───__pycache__
│   │   └───__pycache__
│   ├───interfaces
│   │   ├───alexa
│   │   │   ├───comms
│   │   │   │   ├───messagingcontroller
│   │   │   │   │   └───__pycache__
│   │   │   │   └───__pycache__
│   │   │   ├───presentation
│   │   │   │   ├───apl
│   │   │   │   │   ├───listoperations
│   │   │   │   │   │   └───__pycache__
│   │   │   │   │   └───__pycache__
│   │   │   │   ├───apla
│   │   │   │   │   └───__pycache__
│   │   │   │   ├───aplt
│   │   │   │   │   └───__pycache__
│   │   │   │   ├───html
│   │   │   │   │   └───__pycache__
│   │   │   │   └───__pycache__
│   │   │   └───__pycache__
│   │   ├───amazonpay
│   │   │   ├───model
│   │   │   │   ├───request
│   │   │   │   │   └───__pycache__
│   │   │   │   ├───response
│   │   │   │   │   └───__pycache__
│   │   │   │   ├───v1
│   │   │   │   │   └───__pycache__
│   │   │   │   └───__pycache__
│   │   │   ├───request
│   │   │   │   └───__pycache__
│   │   │   ├───response
│   │   │   │   └───__pycache__
│   │   │   ├───v1
│   │   │   │   └───__pycache__
│   │   │   └───__pycache__
│   │   ├───audioplayer
│   │   │   └───__pycache__
│   │   ├───automotive
│   │   │   └───__pycache__
│   │   ├───connections
│   │   │   ├───entities
│   │   │   │   └───__pycache__
│   │   │   ├───requests
│   │   │   │   └───__pycache__
│   │   │   ├───v1
│   │   │   │   └───__pycache__
│   │   │   └───__pycache__
│   │   ├───conversations
│   │   │   └───__pycache__
│   │   ├───custom_interface_controller
│   │   │   └───__pycache__
│   │   ├───display
│   │   │   └───__pycache__
│   │   ├───gadget_controller
│   │   │   └───__pycache__
│   │   ├───game_engine
│   │   │   └───__pycache__
│   │   ├───geolocation
│   │   │   └───__pycache__
│   │   ├───messaging
│   │   │   └───__pycache__
│   │   ├───monetization
│   │   │   ├───v1
│   │   │   │   └───__pycache__
│   │   │   └───__pycache__
│   │   ├───navigation
│   │   │   ├───assistance
│   │   │   │   └───__pycache__
│   │   │   └───__pycache__
│   │   ├───playbackcontroller
│   │   │   └───__pycache__
│   │   ├───system
│   │   │   └───__pycache__
│   │   ├───tasks
│   │   │   └───__pycache__
│   │   ├───videoapp
│   │   │   └───__pycache__
│   │   ├───viewport
│   │   │   ├───apl
│   │   │   │   └───__pycache__
│   │   │   ├───aplt
│   │   │   │   └───__pycache__
│   │   │   ├───size
│   │   │   │   └───__pycache__
│   │   │   ├───video
│   │   │   │   └───__pycache__
│   │   │   └───__pycache__
│   │   └───__pycache__
│   ├───services
│   │   ├───device_address
│   │   │   └───__pycache__
│   │   ├───directive
│   │   │   └───__pycache__
│   │   ├───endpoint_enumeration
│   │   │   └───__pycache__
│   │   ├───gadget_controller
│   │   │   └───__pycache__
│   │   ├───game_engine
│   │   │   └───__pycache__
│   │   ├───list_management
│   │   │   └───__pycache__
│   │   ├───lwa
│   │   │   └───__pycache__
│   │   ├───monetization
│   │   │   └───__pycache__
│   │   ├───proactive_events
│   │   │   └───__pycache__
│   │   ├───reminder_management
│   │   │   └───__pycache__
│   │   ├───skill_messaging
│   │   │   └───__pycache__
│   │   ├───timer_management
│   │   │   └───__pycache__
│   │   ├───ups
│   │   │   └───__pycache__
│   │   └───__pycache__
│   ├───slu
│   │   ├───entityresolution
│   │   │   └───__pycache__
│   │   └───__pycache__
│   ├───ui
│   │   └───__pycache__
│   └───__pycache__
├───ask_sdk_model-1.24.0.dist-info
├───ask_sdk_runtime
│   ├───dispatch_components
│   │   └───__pycache__
│   ├───view_resolvers
│   │   └───__pycache__
│   └───__pycache__
├───ask_sdk_runtime-1.14.0.dist-info
├───bin
├───cachetools
│   └───__pycache__
├───cachetools-4.1.1.dist-info
├───certifi
│   └───__pycache__
├───certifi-2020.6.20.dist-info
├───chardet
│   ├───cli
│   │   └───__pycache__
│   └───__pycache__
├───chardet-3.0.4.dist-info
├───click
│   └───__pycache__
├───click-7.1.2.dist-info
├───dateutil
│   ├───parser
│   │   └───__pycache__
│   ├───tz
│   │   └───__pycache__
│   ├───zoneinfo
│   │   └───__pycache__
│   └───__pycache__
├───flask
│   ├───json
│   │   └───__pycache__
│   └───__pycache__
├───Flask-1.1.2.dist-info
├───google
│   ├───api
│   │   └───__pycache__
│   ├───api_core
│   │   ├───future
│   │   │   └───__pycache__
│   │   ├───gapic_v1
│   │   │   └───__pycache__
│   │   ├───operations_v1
│   │   │   └───__pycache__
│   │   └───__pycache__
│   ├───auth
│   │   ├───compute_engine
│   │   │   └───__pycache__
│   │   ├───crypt
│   │   │   └───__pycache__
│   │   ├───transport
│   │   │   └───__pycache__
│   │   └───__pycache__
│   ├───logging
│   │   └───type
│   │       └───__pycache__
│   ├───longrunning
│   │   └───__pycache__
│   ├───oauth2
│   │   └───__pycache__
│   ├───protobuf
│   │   ├───compiler
│   │   │   └───__pycache__
│   │   ├───internal
│   │   │   ├───import_test_package
│   │   │   │   └───__pycache__
│   │   │   └───__pycache__
│   │   ├───pyext
│   │   │   └───__pycache__
│   │   ├───util
│   │   │   └───__pycache__
│   │   └───__pycache__
│   ├───rpc
│   │   ├───context
│   │   │   └───__pycache__
│   │   └───__pycache__
│   └───type
│       └───__pycache__
├───googleapis_common_protos-1.52.0.dist-info
├───google_api_core-1.22.0.dist-info
├───google_auth-1.20.0.dist-info
├───idna
│   └───__pycache__
├───idna-2.10.dist-info
├───itsdangerous
│   └───__pycache__
├───itsdangerous-1.1.0.dist-info
├───jinja2
│   └───__pycache__
├───Jinja2-2.11.2.dist-info
├───markupsafe
│   └───__pycache__
├───MarkupSafe-1.1.1.dist-info
├───pkg_resources
│   ├───extern
│   │   └───__pycache__
│   ├───_vendor
│   │   ├───packaging
│   │   │   └───__pycache__
│   │   └───__pycache__
│   └───__pycache__
├───protobuf-3.12.4.dist-info
├───pyasn1
│   ├───codec
│   │   ├───ber
│   │   │   └───__pycache__
│   │   ├───cer
│   │   │   └───__pycache__
│   │   ├───der
│   │   │   └───__pycache__
│   │   ├───native
│   │   │   └───__pycache__
│   │   └───__pycache__
│   ├───compat
│   │   └───__pycache__
│   ├───type
│   │   └───__pycache__
│   └───__pycache__
├───pyasn1-0.4.8.dist-info
├───pyasn1_modules
│   └───__pycache__
├───pyasn1_modules-0.2.8.dist-info
├───python_dateutil-2.8.1.dist-info
├───pytz
│   ├───zoneinfo
│   │   ├───Africa
│   │   ├───America
│   │   │   ├───Argentina
│   │   │   ├───Indiana
│   │   │   ├───Kentucky
│   │   │   └───North_Dakota
│   │   ├───Canada
│   │   └───US
│   └───__pycache__
├───pytz-2020.1.dist-info
├───requests
│   └───__pycache__
├───requests-2.24.0.dist-info
├───rsa
│   └───__pycache__
├───rsa-4.6.dist-info
├───setuptools
│   ├───command
│   │   └───__pycache__
│   ├───extern
│   │   └───__pycache__
│   ├───_distutils
│   │   ├───command
│   │   │   └───__pycache__
│   │   └───__pycache__
│   ├───_vendor
│   │   ├───packaging
│   │   │   └───__pycache__
│   │   └───__pycache__
│   └───__pycache__
├───setuptools-49.2.0.dist-info
├───six-1.15.0.dist-info
├───urllib3
│   ├───contrib
│   │   ├───_securetransport
│   │   │   └───__pycache__
│   │   └───__pycache__
│   ├───packages
│   │   ├───backports
│   │   │   └───__pycache__
│   │   ├───ssl_match_hostname
│   │   │   └───__pycache__
│   │   └───__pycache__
│   ├───util
│   │   └───__pycache__
│   └───__pycache__
├───urllib3-1.25.10.dist-info
├───werkzeug
│   ├───debug
│   │   ├───shared
│   │   └───__pycache__
│   ├───middleware
│   │   └───__pycache__
│   ├───wrappers
│   │   └───__pycache__
│   └───__pycache__
├───Werkzeug-1.0.1.dist-info
└───__pycache__

标签: pythonamazon-web-servicesaws-lambdaalexa-skills-kitaws-lambda-layers

解决方案


啊哈,我想我从你的最后评论中找出了问题所在。根据这个文档,

要将库包含在层中,请将它们放置在运行时支持的文件夹之一中,或者针对您的语言修改该路径变量。

对于 Python,所有库都应该驻留在的目录是python(或者python/lib/pythonX.X/site-packages在这里不是很有用)。

因此,要解决您在这里遇到的问题,只需

  1. zip将文件夹重命名为python
  2. 压缩python本身

推荐阅读