7

我想.py使用 Windows bash 控制台在 Visual Studio Code 中运行 python 文件。

我试图做的事情:

更改默认外壳settings.json

{
    "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
}

将任务添加到以文件名作为参数tasks.json运行命令:python

{
    // 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}"]
        }
    ]
}

这里有几个问题需要解决:

  1. 任务没有按照我的意愿在 bash 中运行
  2. 要访问C驱动器,我需要 在文件路径中C:\替换/mnt/c

你能分享我对这些问题的解决方案吗?

4

1 回答 1

0

我没有 Windows 10,bash但我想问题是你实际上并没有尝试运行 Python。您正在尝试运行bash(然后运行python)。尝试将命令设置为bashwith params ["python", "$file"]

于 2016-09-28T18:55:48.127 回答