【以下的问题经过翻译处理】 您好,我正在使用Python 3.9和AWS Lambda。在lambda函数中,我使用nltk模块进行一些操作。
要创建层,我已执行以下操作:
- 执行:python3.9 -m pip install nltk==3.6.3 -t <<lambda_function>>/python
- 在template.yml中创建一个层,如下所示:
XXXNLTKLayer:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri: <<lambda_function>>/python/
LayerName: nltk-layer
CompatibleRuntimes:
- python3.9
CompatibleArchitectures:
- x86_64
Metadata:
BuildMethod: python3.9
我在发布后的Sam本地调用和AWS控制台中进行测试,但遇到以下错误:
{"errorMessage": "Unable to import module 'app': No module named 'regex._regex'", "errorType": "Runtime.ImportModuleError"
我无法使用Google搜索出的建议解决此问题。我尝试使用最新版本的nltk包,但出现相同的问题。如果有人遇到过这个问题,请为我提供建议。