aws-toolkit-jetbrains
aws-toolkit-jetbrains copied to clipboard
PyCharm Fail on Debug SAM Hello World
Describe the bug Running Local Debug on unmodified hello world project will throw error:
Invoking app.lambda_handler (python3.9)
Local image is up-to-date
Using local image: public.ecr.aws/lambda/python:3.9-rapid-x86_64.
Mounting /Users/guimagni/dev/workspaces/aws/phyton/LambdaPyhton03/.aws-sam/build/Function as /var/task:ro,delegated inside runtime container
START RequestId: 2a4799b6-4241-45db-9440-ff9c920fbb26 Version: $LATEST
/var/lang/bin/python3.9: can't open file '/tmp/lambci_debug_files/pydevd.py': [Errno 2] No such file or directory
24 Mar 2023 16:28:16,598 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 2 InvokeID=
/var/lang/bin/python3.9: can't open file '/tmp/lambci_debug_files/pydevd.py': [Errno 2] No such file or directory
END RequestId: 0f43c63d-ed06-4e91-9e51-70a4fc324ca6
REPORT RequestId: 0f43c63d-ed06-4e91-9e51-70a4fc324ca6 Init Duration: 0.19 ms Duration: 38.85 ms Billed Duration: 39 ms Memory Size: 128 MB Max Memory Used: 128 MB
To reproduce python3 --version Python 3.9.6
- brew install aws/tap/aws-sam-cli
- sam init --runtime python3.9 --dependency-manager pip --app-template hello-world --name HelloWorld
- Open Project With PyCharm (But same error creating project from IDE)
- Debug The default lambda_handler(event, context):

Expected behavior The application start and hit the breakpoint in the implementation
Screenshots There is an error:

Your Environment
- OS: OSX VEntura 13.2.1
- JetBrains product: PyCharm
- JetBrains product version: 2022.3.3 (Professional Edition)
- AWS Toolkit version: 1.62-223
- SAM CLI version: SAM CLI, version 1.76.0
- JVM/Python version: Python 3.9.6
Additional context
- Already added /Applications/PyCharm.app/ in docker file sharing
- If I open the same project with Visual Studio Code it run debug without problem and hit the break point
- I do the same operation with IntelliJ Idea with AWS Toolkit, Java or Javascript, and all run without error, hitting breakpoint
- I do the same operation with GoLand and all tun without error, hitting breakpoint
I am unable to reproduce on a new install of PyCharm Professional 2022.3.3
/var/lang/bin/python3.9: can't open file '/tmp/lambci_debug_files/pydevd.py': [Errno 2] No such file or directory
On Mac, we mount <PYCHARM>/Contents/plugins/python/helpers/pydev
into /tmp/lambci_debug_files
It seems like pydev
isn't in the PyCharm installation for some reason. Have you tried reinstalling PyCharm?
I've a fresh new new installation of PyCharm, downloded to the last version.
The files seems to be there:
It seems that the mount was unsuccessfull.
I've try to delete image from docker causing to build a new one, but still on error.
any updates on this issue? I have the same error
Do you happen to have any updates on the issue? I am encountering the same error as well.
/var/lang/bin/python3.11: can't open file '/tmp/lambci_debug_files/pydevd.py': [Errno 2] No such file or directory
Workaround for M1 Mac/Rancher Desktop (lima): https://stackoverflow.com/a/77803515/8751739
FYI Docker -> Preferences... -> Resources -> File Sharing add /Applications works.
@rumbarum That is only valid for Docker Desktop, right?
I got it fixed, by passing --debugger-path /Users/xyz/pydev to SAM CLI local invoke cmd. you may need to check whether pydev is installed, generally in case if PyCharm on MAC it is here at /Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev (PCharm CE) or /Applications/PyCharm CE.app/Contents/plugins/python/helpers/pydev (PyChram professional), however, copy pydev folder to someother location and pass the path to SAM CLI --debugger-path flag.
@rumbarum That is only valid for Docker Desktop, right?
I'm using Rancher Desktop, works for me if running dockerd as container runtime, so it would be right to say that it may work for Docker Desktop as well..