我在 Golang 中创建了一个示例项目:
sampleapp/
sampleapp/main.go
Run Code Online (Sandbox Code Playgroud)
其中有以下代码:
package main
import (
"flag"
"fmt"
)
func main() {
var name = flag.String("name", "user1", "user name")
var age = flag.Int("age", 20, "user age")
fmt.Println(*name)
fmt.Println(*age)
}
Run Code Online (Sandbox Code Playgroud)
我按照https://code.visualstudio.com/docs/editor/debugging并创建了以下 launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch file",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/main.go",
"env": {},
"args": []
},
{
"name": "Launch exec",
"type": "go",
"request": "launch",
"mode": "exec",
"program": "${workspaceFolder}/sampleapp",
"env": {},
"args": []
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我使用启动文件 …
我正在使用 VS Code for Python(anaconda 包和 OpenCV)。
我正在调试程序(按 F5)并且收到以下错误。
我收到错误的代码
import cv2 as cv
import os
import numpy as np
pathsyn = os.path.realpath("synset_words.txt")
print("path", pathsyn)
syn = open(pathsyn,"r").read().strip().split("\n")
syncls = [r[r.find(" ") +1:] for r in syn]
vid = cv.VideoCapture(0)
net = cv.dnn.readNetFromCaffe("Classifiers/model/bvlc_googlenet.prototxt","Classifiers/model/bvlc_googlenet.caffemodel")
Run Code Online (Sandbox Code Playgroud)
尽管这两个synset_words.txt,AI02.py文件位于同一目录中
如果我将代码修改为
pathsyn = os.path.realpath("OpenCV/synset_words.txt")
Run Code Online (Sandbox Code Playgroud)
然后就可以了。
import cv2 as cv
import os
import numpy as np
pathsyn = os.path.realpath("OpenCV/synset_words.txt")
print("path", pathsyn)
syn = open(pathsyn,"r").read().strip().split("\n")
syncls = [r[r.find(" ") +1:] for r in syn]
vid …Run Code Online (Sandbox Code Playgroud) python opencv atom-editor visual-studio-code vscode-debugger
当尝试在 vscode 中启动调试会话时,它会引发关于未找到指定任务的错误。我已经尝试过类似这样的其他 SO 问题的解决方案,但没有成功。
启动.json:
{
// 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": "MSEventHubs_Audit",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/audit-events.py",
"console": "integratedTerminal",
"args": [
"config/config.ini",
],
"envFile": "${workspaceFolder}/.env",
"env": {"PYTHONPATH": "${workspaceRoot}"},
"justMyCode": false,
"preLaunchTask": {
"task": "audit_tunnel"
}
},
{
...
},
]
}
Run Code Online (Sandbox Code Playgroud)
任务.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the …Run Code Online (Sandbox Code Playgroud) 我在 VSCode(Django 应用程序)中设置了调试,它在默认设置下运行良好。但是,在调试时似乎无法自动重新加载。这在 VSCode文档中说明:
请注意,调试时无法自动重新加载 Django 应用程序。
我在想,如果有一些方法,使调试(断点等)的工作与Django中启用了重装。
当vscode调试我无法读取appsettings.json我的Startup.cs我的WebAPI项目的文件。它们都返回为空/空。
我launch.json的 webapi 配置是通过添加.NET Core Launch (console)配置生成的。我也尝试添加.NET Core Launch (web)配置,但出现同样的问题。
然后我唯一需要更改的是"program"指向项目文件夹中正确 dll的设置。
这是我的 launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/SATestUtils.API/bin/Debug/netcoreapp3.1/SATestUtils.API.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
}
]
}
Run Code Online (Sandbox Code Playgroud)
这是我的 tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/SATestUtils.Api/SATestUtils.API.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}, …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 ubuntu 20.04 上将 xdebug 3 与 docker 一起使用,但我没有成功,xdebug 没有进入中断点,我已经搜索了所有内容,但没有答案解决了我的问题,这可能与 docker 主机有关,因为相同的配置在Windows中是正确的,我不知道我还能尝试什么来解决这个问题,我需要帮助来理解我做错了什么,下面是我的配置。
我的 docker-compose 文件
version: '3.7'
networks:
supervisao:
services:
nginx:
image: nginx:stable-alpine
container_name: supervisao-web
ports:
- "80:80"
volumes:
- .:/var/www/html/
- ./.docker/web/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php
- mysql
networks:
- supervisao
mysql:
image: mysql:latest
container_name: supervisao-db
command: --default-authentication-plugin=mysql_native_password
restart: always
tty: true
ports:
- "3306:3306"
volumes:
- ./.docker/mysql/:/var/lib/mysql
environment:
MYSQL_DATABASE: supervisao
MYSQL_USER: user
MYSQL_PASSWORD: pass
MYSQL_ROOT_PASSWORD: pass
SERVICES_TAGS: dev
SERVICES_NAME: mysql
networks:
- supervisao
php:
build:
context: .
dockerfile: Dockerfile …Run Code Online (Sandbox Code Playgroud) 我试图弄清楚如何在 Visual Studio Code 中进行自定义运行配置,但没有成功找到任何描述我的用例的文档。
我想创建一个运行配置来运行我可以设置来运行我的代码的任意命令。这是必要的,因为我使用的语言没有提供运行配置的扩展。
我确实发现这对于任务是可能的,但我无法弄清楚如何通过按 F5 来运行任务(就像使用运行配置一样)。
所以,这就是我想要做的:定义当我按 F5 时将运行命令(run.exe ${当前选择的 VSCode 文件})的内容。
我不知道如何让 VS Code for Mac 使用我在 launch.json 文件中定义的参数开始调试我的 Python 脚本,方法是使用我在此处圈出的右侧的调试按钮。让我的参数被识别的唯一方法是进入菜单并选择“运行|开始调试”或按 F5。
使用该按钮时如何告诉 VS Code 使用我的 launch.json 文件???
如果您在下面的链接中查看 Sourya Dey 的答案,这就是我写这篇文章的原因。必须有一些简单的设置或缺少步骤才能将该按钮链接到 F5。看来其他人也对此感到困惑。
Visual Studio Code:如何使用参数调试 Python 脚本
为了清楚起见,这里是我的 launch.json 文件,它与 F5 一起按预期工作。它不适用于我上面用红色圈出的按钮
我最近升级了我的vscode,现在当我尝试运行该服务时出现此错误:
D:\herokuworkspace\server/node_modules/.bin/babel-node.CMD --inspect-brk=27776 src\index.js
D:\Program Files\nodejs\node.exe: bad option: --inspect-brk=27776
Run Code Online (Sandbox Code Playgroud)
这是我的配置:
{
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/babel-node",
"name": "Launch Program",
"program": "${workspaceFolder}/src/index.js",
"cwd": "${workspaceRoot}",
"internalConsoleOptions": "openOnSessionStart"
}
Run Code Online (Sandbox Code Playgroud)
请告知我应该在配置中更改什么以使其再次运行.
几天前,VSCode完美运行。尝试通过VSCode运行任何python代码(有或没有调试)都会在终端中导致此错误
can't open file '"c:/Users/Rastus22/.vscode/extensions/ms-python.python-2019.5.17517/pythonFiles/ptvsd_launcher.py"': [Errno 22] Invalid argument
错误显示一小会后,我收到一条消息,告诉我等待调试器超时。python本身没有任何错误,当前正在测试仅包含print语句的文件。我唯一的扩展是Darkula主题。
我尝试重新安装Python扩展并重置launch.json文件以及settings.json文件。我也尝试过从另一台机器复制启动和设置文件的已知良好副本,但是没有运气。我似乎也无法在网上找到其他人遇到同样的问题。
vscode-debugger ×10
python ×3
vscode-tasks ×2
atom-editor ×1
babel-node ×1
debugging ×1
django ×1
docker ×1
go ×1
json ×1
node.js ×1
opencv ×1
php ×1
ubuntu ×1