如圖
一般是由於launch.json文件沒有配置好的緣故。在右下角的ADD configuration如選第二個登錄:
看到program這一欄,這一欄很重要,一般是選擇你CMakelist,編譯出來的可執行文件
看我CMakelist,
我生成的可執行文件是test_,所以路徑可以這樣輸入:
我在之前cmake的時候已經有了test_這個文件了
然后就可以運行/start debugging了,比如我的程序如下(F5調試,shift停止)
簡單一點的launch.json配置
Test.py測試文件名字。
import numpy as np
import cv2
FilePath = './Luffy.jpeg'
## Read image
img = cv2.imread(FilePath,0)
## show your image
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
launch.json配置,新建的時候debug configuration的是python file。改成"program": "${file}",則可以直接F5運行當前文件。
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "./test.py",
// "program": "${file}",
"console": "integratedTerminal"
}
]
}