PyCharm:如何正确连接到本地进程以进行调试
您好,请遵循PyCharm提供的文档:https://www.jetbrains.com/help/pycharm/2017.1/attaching-to-local-process.html我想附加到本地进程以进行调试。
所以我只是为了演示而在没有任何实际用途的情况下在我的running.py文件中编写了一些虚拟代码:
import time
var_not_in_loop_below = 78
counter = 0
while True:
counter += 1
if counter <= 1:
dummy_text = "Dummy"
else:
dummy_text = "Dummies"
print(str(counter) + " " + dummy_text)
time.sleep(2)
loop_var = 42
我可以通过Pycharm附加到脚本,我在Windows cmd中启动:python running.py
然而,PyCharm只是显示了它在控制台部分实际打印的内容,而我却无法在Pycharm中提供的源代码中使用任何方式,对于为何在解释器添加断点时添加断点时为何无法执行或调试代码的想法在IDE旁边的cmd中运行脚本?
谢谢
[编辑] cmd中发生了什么:
$ C:Python278python.exe running.py
1 Dummy
2 Dummies
3 Dummies
4 Dummies
5 Dummies
6 Dummies
7 Dummies
8 Dummies
9 Dummies
10 Dummies
11 Dummies
12 Dummies
13 Dummies
14 Dummies
15 Dummies
16 Dummies
在Pycharm中
Attaching to a process with PID=8620
C:Python278python.exe C:UserseperretAppDataLocalJetBrainsToolboxappsPyCharm-Cch-0171.3780.115helperspydevpydevd_attach_to_processattach_pydevd.py --port 62090 --pid 8620
Connecting to 32 bits target
Injecting dll
Dll injected
Allocating code in target process
Writing code in target process
Allocating return value memory in target process
Injecting code to target process
Waiting for code to complete
Connected to pydev debugger (build 171.3780.115)
Error when injecting code in target process. Error code: 7 (on windows)
10 Dummies
11 Dummies
12 Dummies
13 Dummies
14 Dummies
15 Dummies
16 Dummies
想知道这个问题是否与下面这一行有关:
Error when injecting code in target process. Error code: 7 (on windows)
链接地址: http://www.djcxy.com/p/44955.html
上一篇: PyCharm: how to properly attach to a local process for debugging purposes