vscode python调试报错_【已解决】VSCode调试Python出错:调试适配器进程意外终止Cannot read property ‘style’ of undefined...

最近在用VSCode去调试Python代码,结果时不时的会出错:调试适配器进程意外终止 (Cannot read property 'style' of undefined {"command":"runInTerminal","arguments":{"kind":"integrated","title":"Python Debug Console","cwd":"/Users/crifan/dev/dev_root/company/xxx","args":["/usr/local/bin/python3","/Users/crifan/.vscode/extensions/ms-python.python-2018.11.0/pythonFiles/experimental/ptvsd_launcher.py","--default","--client","--host","localhost","--port","59599","/Users/crifan/dev/dev_root/yyy.py"],"env":{"PYTHONIOENCODING":"UTF-8","PYTHONUNBUFFERED":"1"}},"type":"request","seq":2})

2d9a0ddf5911c381a4f1ee4e4128d5df.png

刚才又出现同样错误了:

在刚调试完毕后,再去(F5)调试,结果就报错了。

之前也遇到类似问题,关闭VSCode再重启就好了。

现在希望彻底解决此问题。

VSCode debug python Cannot read property ‘style’ of undefined {“command”:”runInTerminal”

“Support for removing variables from the environment

The runInTerminal request is used by a debug adapter to launch a debug target in an integrated or external terminal. One parameter to the request is the set of environment variables to pass to the debug target. In this release, null has been added to the environment variable’s value type with the semantics “remove the environment variable from the environment before launching the target”.”

感觉是配置问题,去看看

注意到此处的调试是没有配置:

29b9b9afbb68605b63e5d30af0d19bf2.png

所以需要去加一个默认的配置?

1670a6b4739db0c65604f042260ab247.png

7c24b9187c7b165b9c9e581b7446d07e.png

acb889c6d38f9f94320e92f7de533ad6.png

266e20c10c956c55c3a5d1a85e9d2d16.png

加了后是:    {

"name": "Python: Terminal (integrated)",

"type": "python",

"request": "launch",

"program": "${file}",

"console": "integratedTerminal"

},

发现和现有的一样:

ae4c36a4eca74e0eeff72f4215399640.png

所以还是去删除掉新加的:

保留之前的:    {

"name": "Python: Current File (Integrated Terminal)",

"type": "python",

"request": "launch",

"program": "${file}",

"console": "integratedTerminal"

},

3c3f6d399bc615511d192880f94f2cb6.png

然后切换到当前python文件,再去调试:

87b808de39bad5fee312abbff616f938.png

问题依旧:

42f34e92fb29275858ca8de19df057bf.png调试适配器进程意外终止 (Cannot read property 'style' of undefined {"command":"runInTerminal","arguments":{"kind":"integrated","title":"Python Debug Console","cwd":"/Users/crifan/dev/dev_root/xxx","args":["/usr/local/bin/python3","/Users/crifan/.vscode/extensions/ms-python.python-2018.11.0/pythonFiles/experimental/ptvsd_launcher.py","--default","--client","--host","localhost","--port","65367","/Users/crifan/dev/dev_root/xxx.py"],"env":{"PYTHONIOENCODING":"UTF-8","PYTHONUNBUFFERED":"1"}},"type":"request","seq":2})

感觉python路径不对啊:

/usr/local/bin/python3

不是我现在选择的:

3edba007a8e2e710fb1c8d85f5fd674c.png

发现判断错了,就是当前选的python版本。

7a9a2441dbe5f443fb4c7ae62915086d.png

参考:{

// 使用 IntelliSense 了解相关属性。

// 悬停以查看现有属性的描述。

// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387

-》

此处想要去ll查看文件都挂了:

08b745864f5bbf3021f023df6dae6a4a.png

算了,重启VSCode再说。

删除.vscode目录:

9047e6111ee8d2d22a33bb23e4c0c549.png

重新新建VSCode项目:

be1607a447e61bd39f07aba763b4d737.png

再去调试是否可以调试:

1c79c735240465a1cc32c448c974ef2b.png

去选择python版本

33c722b39947809dfb2324aa61aeb407.png

10d3085fc7dbf887704577e11111a9f5.png

然后就可以正常调试了:

4c3e6159149dffb3e835c0bbef0b000f.png

821a963d98828bf94988f598ea033b2f.png

【总结】

暂时还是没有彻底解决掉,为何会报错:调试适配器进程意外终止 (Cannot read property 'style' of undefined {"command":"runInTerminal","arguments":{"kind":"integrated","title":"Python Debug Console","cwd":"/Users/crifan/dev/dev_root/xxx","args":["/usr/local/bin/python3","/Users/crifan/.vscode/extensions/ms-python.python-2018.11.0/pythonFiles/experimental/ptvsd_launcher.py","--default","--client","--host","localhost","--port","59599","/Users/crifan/dev/dev_root/xxx.py"],"env":{"PYTHONIOENCODING":"UTF-8","PYTHONUNBUFFERED":"1"}},"type":"request","seq":2})

而只是重启VSCode或删除.vscode,重建项目,重新选择Python解析器,添加基本的debug配置,才能正常调试。

【后记】

但是此处郁闷的是,几秒前可以调试,但是接着重新调试就不行了

VSCode调试python 调试适配器进程意外终止

“卸载python调试插件以后重装插件,就解决了”

现在大意像是明白了:

Python的调试的插件,对于:{"command":"runInTerminal","arguments":{"kind":"integrated","title":"Python Debug Console","cwd":"/Users/crifan/dev/dev_root/xxx","args":["/usr/local/opt/python/bin/python3.6","/Users/crifan/.vscode/extensions/ms-python.python-2018.11.0/pythonFiles/experimental/ptvsd_launcher.py","--default","--client","--host","localhost","--port","56965","/Users/crifan/dev/dev_root/xxx.py"],"env":{"PYTHONIOENCODING":"UTF-8","PYTHONUNBUFFERED":"1"}},"type":"request","seq":2}

-》{

"command": "runInTerminal",

"arguments": {

"kind": "integrated",

"title": "Python Debug Console",

"cwd": "/Users/crifan/dev/dev_root/xxx",

"args": ["/usr/local/opt/python/bin/python3.6", "/Users/crifan/.vscode/extensions/ms-python.python-2018.11.0/pythonFiles/experimental/ptvsd_launcher.py", "--default", "--client", "--host", "localhost", "--port", "56965", "/Users/crifan/dev/dev_root/xxx.py"],

"env": {

"PYTHONIOENCODING": "UTF-8",

"PYTHONUNBUFFERED": "1"

}

},

"type": "request",

"seq": 2

}

这种(类型的)配置,不认,无法识别。

然后才报错的。

此处再去确认python是没问题的:➜  测试 git:(master) ✗ ll /usr/local/opt/python/bin/python3.6

lrwxr-xr-x  1 crifan  admin    57B 12 19  2017 /usr/local/opt/python/bin/python3.6 -> ../Frameworks/Python.framework/Versions/3.6/bin/python3.6

突然发现一个貌似可行的办法:

关闭掉当前的Terminal终端,然后会重新显示一个新的终端

然后就可以正常调试了:

1cca70dc9ff4ad471b43aad226c867e2.png

-》推测是之前的,此处调试报错时,终端已经出问题了,导致影响了调试。

【总结】

对于VSCode的python调试,突然会无法调试,报错:调试适配器进程意外终止 (Cannot read property 'style' of undefined {"command":"runInTerminal","arguments":{"kind":"integrated"...

原因:未知

解决方案:

后来经过几次实际测试,我这个办法是可以解决问题的:

点击VSCode的 垃圾箱的那个按钮删除掉当前Terminal终端

然后重新F5开始调试,会自动新生成新的Terminal终端

-》这样就可以正常继续调试了。

-》看来问题是可能是之前的终端有问题而引起的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值