vscode调试python文件时出现错误AttributeError: 'NoneType' object has no attribute 'startswith'

问题描述:

  from ._conv import register_converters as _register_converters
Traceback (most recent call last):
  File "/home/ubuntu/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 284, in _on_run
    self.process_net_command_json(self.global_debugger_holder.global_dbg, json_contents)
  File "/home/ubuntu/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 137, in process_net_command_json
    cmd = on_request(py_db, request)
  File "/home/ubuntu/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 526, in on_evaluate_request
    py_db, request, thread_id)
  File "/home/ubuntu/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_api.py", line 385, in request_exec_or_evaluate_json
    thread_id, internal_evaluate_expression_json, request, thread_id)
  File "/home/ubuntu/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/pydevd.py", line 843, in post_method_as_internal_command
    self.post_internal_command(internal_cmd, thread_id)
  File "/home/ubuntu/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/pydevd.py", line 847, in post_internal_command
    queue = self.get_internal_queue(thread_id)
  File "/home/ubuntu/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/pydevd.py", line 834, in get_internal_queue
    if thread_id.startswith('__frame__'):
AttributeError: 'NoneType' object has no attribute 'startswith'

解决方案:

主要对pydevd.py文件进行修改,路径要根据自己需要进行修改,例如我的路径: "/home/ubuntu/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/lib/python/ptvsd/_vendored/pydevd/pydevd.py"

修改为如下所示:

        global connected
        connected = True  # Mark that we're connected when started from inside ide.

        run(debugger, setup, is_module)

def run(debugger, setup, is_module):
    globals = debugger.run(setup['file'], None, None, is_module)
    if setup['cmd-line']:
        debugger.wait_for_commands(globals)

 

参考:

VSCode跑完Python会挂的原因及解决

mac电脑调试python文件时出现错误if setup['cmd-line']: TypeError: 'NoneType' object is not callable

python安装包错误AttributeError: 'NoneType' object has no attribute 'startswith'

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值