Reputation: 6415
I'm following Microsoft's guide Getting Started with Python in VS Code, but can only run in debug mode once -- the following run will always hit a time out issue.
This is the hello.py
msg = "Hello World"
print(msg)
This is the launch.json
, which basically only added "stopOnEntry": true
so will stop at the first line of code during debugging:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"stopOnEntry": true
}
]
}
So my first round of debugging works, the terminal inside Visual Studio Code shows:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Playground\vscode\py\ms>c:/Playground/vscode/py/ms/env/Scripts/activate.bat
(env) C:\Playground\vscode\py\ms>cd c:\Playground\vscode\py\ms && cmd /C "set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && c:\Playground\vscode\py\ms\env\Scripts\python.exe c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\ptvsd_launcher.py --default --client --host localhost --port 58792 c:\Playground\vscode\py\ms\hello.py "
Hello World
However, if I click debug
button again, it jammed, showing an error dialogue:
[Window Title]
Visual Studio Code
[Content]
timeout
[Open launch.json] [Cancel]
, and Terminal inside vscode shows:
(env) C:\Playground\vscode\py\ms>cd c:\Playground\vscode\py\ms && cmd /C "set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && c:\Playground\vscode\py\ms\env\Scripts\python.exe c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\ptvsd_launcher.py --default --client --host localhost --port 58798 c:\Playground\vscode\py\ms\hello.py "
E00001.107: Exception escaped from start_client
Traceback (most recent call last):
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\log.py", line 110, in g
return f(*args, **kwargs)
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\pydevd_hooks.py", line 74, in start_client
sock, start_session = daemon.start_client((host, port))
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\daemon.py", line 217, in start_client
connect(client, addr)
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\socket.py", line 197, in connect
sock.connect(addr)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
Traceback (most recent call last):
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\ptvsd_launcher.py", line 43, in <module>
main(ptvsdArgs)
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\__main__.py", line 434, in main
run()
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\__main__.py", line 296, in run_file
setup_connection()
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\__main__.py", line 287, in setup_connection
daemon = ptvsd._remote.attach(addr)
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\_remote.py", line 91, in attach
patch_multiprocessing=ptvsd.options.multiprocess)
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\_vendored\pydevd\pydevd.py", line 2017, in settrace
wait_for_ready_to_run,
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\_vendored\pydevd\pydevd.py", line 2068, in _locked_settrace
debugger.connect(host, port) # Note: connect can raise error.
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\_vendored\pydevd\pydevd.py", line 914, in connect
s = start_client(host, port)
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\pydevd_hooks.py", line 132, in <lambda>
_start_client = (lambda h, p: start_client(daemon, h, p))
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\log.py", line 110, in g
return f(*args, **kwargs)
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\pydevd_hooks.py", line 74, in start_client
sock, start_session = daemon.start_client((host, port))
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\daemon.py", line 217, in start_client
connect(client, addr)
File "c:\Users\drlren\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\lib\python\ptvsd\socket.py", line 197, in connect
sock.connect(addr)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
What happened? and how can I sort it out?
Upvotes: 5
Views: 4410
Reputation: 1167
I had the same timeout problem on VS Code with a freshly installed Python Extension by Microsoft. What I did was installing the plugin and then immediately try to debug a file, which ended in a ConnectionRefusedError
.
To resolve, I simply restarted VS Code.
Upvotes: 1
Reputation: 190
I resolved this issue changing the terminal from "bash" to "Command prompt" (cmd).
Upvotes: 4