每当我尝试调试python代码时,vscode都会给出一个错误,并通知我调试器的连接被拒绝。我在底部附上了完整的堆栈跟踪
我用的是CentOS 8 Linux。
到目前为止,我已经尝试过:
- SELinux关闭
- 防火墙已禁用
- 卸载vscode
- remove /home/user/.vscode
- remove /home/user/.config/Code
- 清除环境变量
不知道是什么干扰了这里。
我正在调试的文件是print('test')
,保存为test.py:-)
/usr/bin/python /home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 43259 /scratch/user/tmp/test.py
E00000.119: Exception escaped from start_client
Traceback (most recent call last):
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/log.py", line 110, in g
return f(*args, **kwargs)
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/pydevd_hooks.py", line 74, in start_client
sock, start_session = daemon.start_client((host, port))
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 217, in start_client
connect(client, addr)
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/socket.py", line 197, in connect
sock.connect(addr)
ConnectionRefusedError: [Errno 111] Connection refused
Traceback (most recent call last):
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/ptvsd_launcher.py", line 43, in <module>
main(ptvsdArgs)
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 432, in main
run()
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 300, in run_file
setup_connection()
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 291, in setup_connection
daemon = ptvsd._remote.attach(addr)
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/_remote.py", line 95, in attach
patch_multiprocessing=ptvsd.options.multiprocess)
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 2179, in settrace
wait_for_ready_to_run,
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 2230, in _locked_settrace
debugger.connect(host, port) # Note: connect can raise error.
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 1060, in connect
s = start_client(host, port)
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/pydevd_hooks.py", line 136, in _start_client
return start_client(daemon, h, p)
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/log.py", line 110, in g
return f(*args, **kwargs)
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/pydevd_hooks.py", line 74, in start_client
sock, start_session = daemon.start_client((host, port))
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 217, in start_client
connect(client, addr)
File "/home/user/.vscode/extensions/ms-python.python-2020.1.58038/pythonFiles/lib/python/old_ptvsd/ptvsd/socket.py", line 197, in connect
sock.connect(addr)
ConnectionRefusedError: [Errno 111] Connection refused
dmaarten
2条答案
按热度按时间sdnqo3pr1#
我也有同样的问题,经过长时间的研究,我找到了我问题的原因:
1.我的/etc/hosts文件中的localhost不是127.0.0.1
1.因此,DebugAdapter不会侦听地址127.0.0.1
1.因此,“ptvsd --client --host localhost”无法连接到DebugAdapter
解决方案:
在lanuch.json中将主机定义为127.0.0.1
c8ib6hqw2#
在我的情况下是一个完全错误的vscode设置。
venv
)Python: Flask
配置运行调试器