aws-samples / aws-samples/aws-textract-document-data-extraction-platform

"No module named ...._python_runtime" error happened when lambda running

Open
#37 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
14
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Got the below run time error when lambda function running in AWS: "_[ERROR] Runtime.ImportModuleError: Unable to import module 'aws_document_extraction_platform_api_python_handlers.get_metrics': No module named 'aws_document_extraction_platform_api_python_runtime' Traceback (most recent call last):_"

And looks like the issue caused by the folder of "aws_document_extraction_platform_api_python_runtime" not included in the folder of "packages/lib/dist/lambda"

After inserting the below codes into .projerc.ts, the issue fixed in my testing:

// this line code to resolve the ...python_runtime dependencies for step functions
```
pythonLibrary.packageTask.exec(
`cp -r ${path.join('../api/generated/runtime/python/aws_document_extraction_platform_api_python_runtime')} dist/lambda/`
);
```

// this line code to resolve the ...python_runtime dependencies for api handlers
```
api.handlers.python!.packageTask.exec(
`cp -r ${path.join('../../generated/runtime/python/aws_document_extraction_platform_api_python_runtime')} dist/lambda/`
);
```

Contributor guide

Open the contributing guide

Research direction

Start in .projerc.ts and inspect how packages/lib/dist/lambda is assembled for the AWS Lambda handlers and step functions. Reproduce the reported import failure, verify that aws_document_extraction_platform_api_python_runtime is included in the deployment folder, and confirm the get_metrics handler loads successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python, typescript
Domain
backend, cloud
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.