1
我需要帮助配置我的Vs代码来使用Cntrl Shift B运行Python中的脚本,我一直工作正常,直到Vs代码升级到2.0.0版本,现在它希望我配置生成。我无能为力的是什么。配置Vs代码版本2.0.0构建任务python
过去它运行良好,当我只需要配置任务运行器。有任务运行者的youtube视频。我似乎无法指望Build的内容。
我需要帮助配置我的Vs代码来使用Cntrl Shift B运行Python中的脚本,我一直工作正常,直到Vs代码升级到2.0.0版本,现在它希望我配置生成。我无能为力的是什么。配置Vs代码版本2.0.0构建任务python
过去它运行良好,当我只需要配置任务运行器。有任务运行者的youtube视频。我似乎无法指望Build的内容。
在VS代码去任务 - >配置任务
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "Run File",
"command": "python ${file}",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new",
"focus": true
}
},
{
"taskName": "nosetest",
"command": "nosetests -v",
"type": "shell",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new",
"focus": true
}
}
]
}
command
:运行当前的Python文件
group
: '构建'
presentation
:
第二个任务被配置为默认测试,并且只在当前在VS代码中打开的文件夹中运行nosetest -v
。
“运行生成任务”是的已配置为默认的构建任务,任务1在这个例子中(见group
条目)的一个(这是必然Ctrl
+ Shift
+ B
的一个)。
编辑:
建议通过在注释中@RafaelZayas(这将使用在VS代码的设置,而不是系统默认指定的Python解释器,看到他的更多信息评论):
"command": "${config:python.pythonPath} ${file}"
我试过你的代码,但它显示错误'>执行任务:python d:\ books \ programming语言\ python \ Projects \ .vscode \ tasks.json < C:\ Users \ [myuser] \ Anaconda3 \ python.exe :无法打开文件'd:\ books \ programming':[Errno 2]没有这样的文件或目录 终端进程以exit co终止de:1' – FSm
我可以推荐:“command”:“$ {config:”python.pythonPath} $ {file}“用配置变量代替python将使用与Python代码扩展中设置的相同的pythonPath。如果在Windows上,这将与cmd.exe或PowerShell一起运行。根据哪个(我认为PowerShell适用于Win 10或更高版本),在$ file变量周围放置单引号或双引号,即“command”:“$ {config:python.pythonPath}'$ {file}'” –