Pio*_*rek 7 python visual-studio-code windows-subsystem-for-linux
我想.py使用Windows bash控制台在Visual Studio代码中运行python 文件.
我试图做的:
更改默认shell settings.json:
{
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
}
Run Code Online (Sandbox Code Playgroud)
将任务添加tasks.json到python以文件名作为参数的run 命令:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "python",
"isShellCommand": true,
"showOutput": "always",
"tasks": [
{
"taskName": "Run python in bash",
"suppressTaskName": true,
"args": ["${file}"]
}
]
}
Run Code Online (Sandbox Code Playgroud)
这里有一些问题需要解决:
C驱动器,我需要替换 C:\为/mnt/c文件路径您可以与我的解决方案分享这些问题吗?
我没有 Windows 10 bash,但我想问题是你实际上并没有尝试运行 Python。您正在尝试运行bash(然后运行python)。尝试将命令设置为bashwith params ["python", "$file"]。