Debugging local github fork in project using this fork.

huangapple go评论68阅读模式
英文:

VSCode Debugging local github fork in project using this fork

问题

我正在项目A上工作(这是我本地机器上的一个文件夹),在macOS上使用VSCode,并且已经通过pip install -e path_to_projectB在项目A的虚拟环境中安装了项目B(也是我本地机器上的一个文件夹),这样我对项目B所做的更改会立即生效,而无需重新安装任何内容。

我在项目A中有一个名为my_script.py的脚本,它使用了项目B的一个已安装模块,并且我想要在运行my_script.py时调试导入的模块。然而,我在项目B上设置的断点在VSCode中无法捕获。

我的launch.json文件(属于项目A)如下所示:

{
    "name": "python: my_script",
    "type": "python",
    "request": "launch",
    "program": "${workspaceFolder}/src/my_script.py",
    "console": "integratedTerminal",
    "justMyCode": false
}

请注意,我已经将您提供的代码片段中的HTML实体字符(例如")还原为正常的引号字符。如果需要进一步帮助,请告诉我。

英文:

I am working on projectA (which is a folder on my local machine) in VSCode (on macOS) and i have installed projectB (also a folder on my local machine) in the virtual environment of projectA using pip install -e path_to_projectB so that changes i make to projectB are immediately active and i don't need to reinstall anything.

I have a script in projectA called my_script.py, that uses an installed module of projectB and i want to debug that imported module within the run of my_script.py.
However, breakpoints i have set on projectB are not catched by VSCode.

My launch.json file (of projectA) looks like this:

{
    "name": "python: my_script",
     "type": "python",
     "request": "launch",
     "program": "${workspaceFolder}/src/my_script.py",
     "console": "integratedTerminal",
     "justMyCode": false,
}

答案1

得分: 0

为了使VSCode能够在projectB中找到断点,必须将其添加到projectA的工作区中:

  1. 在VSCode中打开projectA
  2. 在文件浏览器中右键单击,选择“将文件夹添加到工作区...”并添加projectB的文件夹
  3. 在新创建的工作区中打开projectB中的文件,在所需位置设置断点。

现在,在运行my_script.py时,您在projectB中设置的断点将会按预期停止运行。
launch.json中,"justMyCode"也可以保持为true。

我的问题是,我在一个单独的VSCode窗口中同时打开了两个文件夹。这样,projectB的断点不会停止my_script.py的运行。

英文:

For VSCode to find breakpoints in projectB, it must be added to the workspace of projectA:

  1. Open projectA in VSCode
  2. Right click inside the file browser and select "Add folder to workspace..." and add the folder of projectB
  3. Add breakpoints at the desired positions in projectB, by opening the files from projectB within this newly created workspace.

Now, when running my_script.py the breakpoints you set in projectB will stop the run as expected.
In launch.json "justMyCode" can also stay true.

My problem was that I had both folders open in a separate VSCode window. This way the breakpoints of projectB did not stop the run of my_script.py.

huangapple
  • 本文由 发表于 2023年6月30日 03:40:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76584164.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定