英文:
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的工作区中:
- 在VSCode中打开projectA
- 在文件浏览器中右键单击,选择“将文件夹添加到工作区...”并添加projectB的文件夹
- 在新创建的工作区中打开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:
- Open projectA in VSCode
- Right click inside the file browser and select "Add folder to workspace..." and add the folder of projectB
- 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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论