aws / chalice

Python Serverless Microframework for AWS
Apache License 2.0
10.67k stars 1.01k forks source link

Chalice cannot get debugging to work #1785

Open Tmilly opened 3 years ago

Tmilly commented 3 years ago

I'm using PyCharm and have tried following all articles available to try and get debugging to work. Ideally I tried getting a configuration to work as below:

image

but that only resulted in

C:\Users\torra\.virtualenvs\nlb-api\Scripts\python.exe C:\Users\torra\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\212.4746.96\plugins\python\helpers\pydev\pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 53324 --file C:/Users/torra/.virtualenvs/nlb-api/Scripts/chalice.exe local --no-autoreload --port 8080
Connected to pydev debugger (build 212.4746.96)
Traceback (most recent call last):
  File "C:\Users\torra\AppData\Local\Programs\Python\Python39\lib\tokenize.py", line 330, in find_cookie
    line_string = line.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\torra\AppData\Local\Programs\Python\Python39\lib\tokenize.py", line 394, in open
    encoding, lines = detect_encoding(buffer.readline)
  File "C:\Users\torra\AppData\Local\Programs\Python\Python39\lib\tokenize.py", line 371, in detect_encoding
    encoding = find_cookie(first)
  File "C:\Users\torra\AppData\Local\Programs\Python\Python39\lib\tokenize.py", line 335, in find_cookie
    raise SyntaxError(msg)
SyntaxError: invalid or missing encoding declaration for 'C:/Users/torra/.virtualenvs/nlb-api/Scripts/chalice.exe'
python-BaseException

Process finished with exit code 1

I also tried attaching to an existing process but that resulted in:

C:\Users\torra\.virtualenvs\nlb-api\Scripts\python.exe C:\Users\torra\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\212.4746.96\plugins\python\helpers\pydev\pydevd_attach_to_process\attach_pydevd.py --port 56075 --pid 18952
Traceback (most recent call last):
  File "C:\Users\torra\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\212.4746.96\plugins\python\helpers\pydev\pydevd_attach_to_process\attach_pydevd.py", line 88, in <module>
    main(process_command_line(sys.argv[1:]))
  File "C:\Users\torra\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\212.4746.96\plugins\python\helpers\pydev\pydevd_attach_to_process\attach_pydevd.py", line 83, in main
    add_code_to_python_process.run_python_code(
  File "C:\Users\torra\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\212.4746.96\plugins\python\helpers\pydev\pydevd_attach_to_process\add_code_to_python_process.py", line 306, in run_python_code_windows
    assert resolve_label(process, b'PyGILState_Ensure')
  File "C:\Users\torra\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\212.4746.96\plugins\python\helpers\pydev\pydevd_attach_to_process\add_code_to_python_process.py", line 266, in resolve_label
    address = process.resolve_label(label)
  File "C:\Users\torra\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\212.4746.96\plugins\python\helpers\pydev\pydevd_attach_to_process\winappdbg\module.py", line 1546, in resolve_label
    address = self.resolve_label_components(module, function, offset)
  File "C:\Users\torra\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\212.4746.96\plugins\python\helpers\pydev\pydevd_attach_to_process\winappdbg\module.py", line 1635, in resolve_label_components
    raise RuntimeError(msg)
RuntimeError: Function b'PyGILState_Ensure' not found in any module

Has anyone else been able to get to debug chalice?

rehanvdm commented 2 years ago

Same problem here, @Tmilly have you solved/worked around it yet?