microsoft / ptvsd

Python debugger package for use with Visual Studio and Visual Studio Code.
Other
548 stars 68 forks source link

Unable to connect to ptvsd because of exception. #2115

Closed m-busch closed 4 years ago

m-busch commented 4 years ago

I am unable to connect from my Windows 7 Visual Studio 2017 with "Attach to Process" to my Raspberry Pi Flask process. I search the Forum but did not fine a solution. No I hope do get a new Idea ... It seems to try to connect but then just displays this Message:

Could not connect to remote Python process at tcp:///. Make sure the process has called ptvsd.enable_attach() and is still running.

I am using: VS 2017 Pro Python 3.7.3 ptvsd 4.3.2

Env settings on my PI are:

FLASK_APP="app.py" FLASK_ENV="development" FLASK_DEBUG=True

I start flask app with one of this commands. All behave similar:

python3 -m ptvsd --host 0.0.0.0 --port 5678 --log-dir ./ptvsd.log app.py python3 -m ptvsd --host 0.0.0.0 --port 5678 --log-dir ./ptvsd.log --multiprocess app.py python3 -m ptvsd --host 0.0.0.0 --port 5678 --multiprocess -m flask run

Flask App start loocks okay to me:

Tail into to the PTVSD-Log File shows strange exceptions?

tail -f ptvsd-22958.log D00000.333: Getting next session... D00000.334: Session lock acquired. D00000.334: Getting session socket... I00000.459: Running file app.py D00000.466: Adding to sys.path. D00042.700: Starting session... D00042.718: IDE <-- { "type": "event", "seq": 0, "event": "output", "body": { "category": "telemetry", "output": "ptvsd", "data": { "version": "4.3.2" } } } D00042.726: Session started. I00047.717: Client socket closed Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/ptvsd/ipcjson.py", line 269, in process_one_message msg = self.message.pop(0) IndexError: pop from empty list During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/ptvsd/ipcjson.py", line 274, in process_one_message msg = self.message.pop(0) IndexError: pop from empty list During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/ptvsd/wrapper.py", line 521, in process_messages self.process_messages() File "/usr/local/lib/python3.7/dist-packages/ptvsd/ipcjson.py", line 258, in process_messages self.process_one_message() File "/usr/local/lib/python3.7/dist-packages/ptvsd/ipcjson.py", line 280, in process_one_message raise EOFError('no more messages') EOFError: no more messages D00047.724: Raw closing D00047.726: Message processor is closing. D00047.728: Handling closing session D00047.730: Message processor is stopping. D00047.731: Getting next session...

int19h commented 4 years ago

Try using https://github.com/microsoft/debugpy on the server.

m-busch commented 4 years ago

Unfortunately I do not see much valuable information. Maybe you can help ...

Started with: python3 -m debugpy --listen 0.0.0.0:5678 --log-to ./ptvsd.log app.py

Log Files: ptvsd.log/debugpy.adapter-26193.log I+00139.052: Accepted incoming Client connection from 192.168.178.10:52795. D+00139.063: Starting message loop for channel Client[2] D+00139.078: Client[2] <-- { "seq": 1, "type": "event", "event": "output", "body": { "category": "telemetry", "output": "ptvsd", "data": { "packageVersion": "1.0.0b5" } } } D+00139.086: Client[2] <-- { "seq": 2, "type": "event", "event": "output", "body": { "category": "telemetry", "output": "debugpy", "data": { "packageVersion": "1.0.0b5" } } } D+00144.052: Exiting message loop for channel Client[2]: No more messages D+00144.065: Closing Client[2] message stream I+00144.077: /handling disconnect from Client[2]/ Session[2] has ended. I+00144.084: /handling disconnect from Client[2]/ Client[2] has disconnected; finalizing Session[2]. I+00144.090: /handling disconnect from Client[2]/ Session[2] finalized.

ptvsd.log/debugpy.adapter-26193.log
CPython 3.7.3 (32-bit) debugpy 1.0.0b5 I+00000.489: debugpy.adapter startup environment: System paths: sys.prefix: /usr sys.base_prefix: /usr sys.real_prefix: site.getsitepackages(): /usr/lib/python3.7/dist-packages /usr/lib/python3/dist-packages /usr/local/lib/python3.7/dist-packages site.getusersitepackages(): /home/mbusch/.local/lib/python3.7/site-packages sys.path (site-packages): /home/mbusch/.local/lib/python3.7/site-packages sysconfig.get_path('stdlib'): /usr/lib/python3.7 sysconfig.get_path('platstdlib'): /usr/lib/python3.7 sysconfig.get_path('purelib'): /usr/lib/python3.7/site-packages sysconfig.get_path('platlib'): /usr/lib/python3.7/site-packages sysconfig.get_path('include'): /usr/include/python3.7m sysconfig.get_path('scripts'): /usr/bin sysconfig.get_path('data'): /usr os.file: /usr/lib/python3.7/os.py threading.file: /usr/lib/python3.7/threading.py I+00000.492: Listening for incoming Client connections on 0.0.0.0:5678... I+00000.498: Listening for incoming Server connections on 127.0.0.1:37205... I+00000.503: Sending endpoints info to debug server at localhost:35995: { "client": { "host": "0.0.0.0", "port": 5678 }, "server": { "host": "127.0.0.1", "port": 37205 } }

int19h commented 4 years ago

Oh, I wonder if VS 2017 can actually connect to this version! @huguesv, do you remember if the last version of the extension for 2017 does a direct socket connection for "attach" and hands it over to VS, or it tries to wrap the DAP stream somehow?

int19h commented 4 years ago

I'm afraid you'll need to use VS 2019 to attach to debugpy.