Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug locally: "ImportError: No module named debugpy" #3075

Closed
marciogoulart opened this issue Dec 30, 2022 · 5 comments
Closed

Debug locally: "ImportError: No module named debugpy" #3075

marciogoulart opened this issue Dec 30, 2022 · 5 comments
Labels
cdk guidance General information and guidance, answers to FAQs, or recommended best practices/resources. language:python Issues related to debugging Python lambdas using SAM Local needs-response Waiting on reply from issue/PR author. platform:windows sam

Comments

@marciogoulart
Copy link

System details (run the AWS: About Toolkit command)

  • OS: Microsoft Windows 10
  • Visual Studio Code version: 1.74.2
  • AWS Toolkit version: 1.59.0

Question

Hi,

I would like support to debug a lambda built in CDK locally in VSCODE.

When I run the lambda via SAM LOCAL INVOKE it works perfectly, but when I add a breakpoint and run it in debug mode, some problems arise.

I performed some tests, the
aws_toolkit.log
main problem is not finding the debugpy module, but it is attached.

@marciogoulart marciogoulart added the guidance General information and guidance, answers to FAQs, or recommended best practices/resources. label Dec 30, 2022
@marciogoulart
Copy link
Author

lauch.json:

{
"configurations": [
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "CodeverifyLocationLambda",
"invokeTarget": {
"target": "code",
"projectRoot": "VerifyLocationLambda",
"lambdaHandler": "verifyLocationLambda.lambda_handler"
},
"sam": {
"localArguments": [
"--template",
"${workspaceFolder}/NaasVerifyLocationRepository/infra/cdk.out/VerifyLocationFunctionStack.template.json",
"--debug"
]
},
"lambda": {
"runtime": "python3.8",
"memoryMb": 128,
"timeoutSec": 30,
"payload": {
"path": "${workspaceFolder}/NaasVerifyLocationRepository/infra/test.json"
},
"environmentVariables": {
"AWS_PROFILE": "outposts-stage"
},
},
}
]
}

@JadenSimon JadenSimon added platform:windows sam language:python Issues related to debugging Python lambdas using SAM Local labels Jan 4, 2023
@JadenSimon
Copy link
Contributor

JadenSimon commented Jan 4, 2023

Hey @marciogoulart,

Our support for CDK-generated templates is basically non-existent so it's hard to say where exactly the problem is. One error from your logs does stand out to me (as you've already mentioned):

ImportError: No module named debugpy

I believe this could be due to using layers. Perhaps explicitly adding debugpy as a dependency for your project will fix things.

@JadenSimon JadenSimon added the needs-response Waiting on reply from issue/PR author. label Jan 4, 2023
@justinmk3 justinmk3 added the cdk label Jan 6, 2023
@justinmk3
Copy link
Contributor

@justinmk3 justinmk3 changed the title Debug locally Debug locally: "ImportError: No module named debugpy" May 16, 2023
@arash-cid
Copy link

reopen this 💩 please

@justinmk3
Copy link
Contributor

justinmk3 commented Oct 25, 2023

@arash-cid this is tracked in #2468 , which also mentions a workaround.

Please keep comments constructive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cdk guidance General information and guidance, answers to FAQs, or recommended best practices/resources. language:python Issues related to debugging Python lambdas using SAM Local needs-response Waiting on reply from issue/PR author. platform:windows sam
Projects
None yet
Development

No branches or pull requests

4 participants