Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Allow clients to debug code from command line, like pdb or epdb

未关闭
#1,568 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
cli, devtools

调研方向

从 debugpy/main.py 和 server/cli.py 开始,然后通过 server/api.py 和 vendored 的 pydevd 文件跟踪报告的路径。重现 OutputEvent/command 失败,并确定是否支持命令行调试和交互式 shell 调试。当约定的命令行工作流能够正常运行且不再出现此失败,并且其用法已记录在文档中时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

Hi there,
in my company many don't use VSCode. For this reason our main guidelines to debug are to use pdb or epdb. (https://pypi.org/project/epdb/)
However, in an effort to have just one library that works for all use cases, I'd like to have debugpy to work from command line too.

I have tried this:

python -m debugpy --connect 5678 <path of the file with debugpy.listen()> 

Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 252, in _on_run
    self.process_net_command_json(self.py_db, json_contents)
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 171, in process_net_command_json
    method_name = 'on_%s_request' % (request.command.lower(),)
AttributeError: 'OutputEvent' object has no attribute 'command'
^CTraceback (most recent call last):
  File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/server/cli.py", line 430, in main
    run()
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/server/cli.py", line 268, in run_file
    start_debugging(target)
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/server/cli.py", line 258, in start_debugging
    debugpy.connect(options.address, access_token=options.adapter_access_token)
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/public_api.py", line 31, in wrapper
    return wrapped(*args, **kwargs)
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/server/api.py", line 141, in debug
    return func(address, settrace_kwargs, **kwargs)
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/server/api.py", line 297, in connect
    _settrace(host=host, port=port, client_access_token=access_token, **settrace_kwargs)
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/server/api.py", line 45, in _settrace
    return pydevd.settrace(*args, **kwargs)
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/_vendored/pydevd/pydevd.py", line 2821, in settrace
    _locked_settrace(
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/_vendored/pydevd/pydevd.py", line 2929, in _locked_settrace
    py_db.wait_for_ready_to_run()
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/_vendored/pydevd/pydevd.py", line 838, in wait_for_ready_to_run
    self._py_db_command_thread_event.wait(0.1)
  File "/usr/local/lib/python3.8/threading.py", line 558, in wait
    signaled = self._cond.wait(timeout)
  File "/usr/local/lib/python3.8/threading.py", line 306, in wait
    gotit = waiter.acquire(True, timeout)

doesn't stop in debug.

I've also tried to use debugpy in python shell:

>>> import debugpy
>>> debugpy.connect(5678)
Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 252, in _on_run
    self.process_net_command_json(self.py_db, json_contents)
  File "/root/.cache/pypoetry/virtualenvs/viralize-adserver-9TtSrW0h-py3.8/lib/python3.8/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 171, in process_net_command_json
    method_name = 'on_%s_request' % (request.command.lower(),)
AttributeError: 'OutputEvent' object has no attribute 'command'

What is supposed to be this "command"?

Also, am I doing something that is intended to be used like this, or what? I think no, because there is no such reference on the web.

主要语言
Python
星标
2.5k
派生
202
平均合并
5 天 1 小时
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/debugpy 的其他 Issue

查看 microsoft/debugpy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。