我想使用 Windows bash 控制台在 Visual Studio Code 中运行 python .py
文件。
我尝试做的事情:
在 settings.json
中更改默认 shell:
{
"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}"]
}
]
}
这里有几个问题需要解决:
- 任务没有按照我的意愿在 bash 中运行
- 访问
C
驱动器 I need to replaceC:\
文件路径为/mnt/c
你能分享我解决这些问题的方法吗?
最佳答案
我没有带 bash
的 Windows 10,但我想问题在于您实际上并没有尝试运行 Python。您正在尝试运行 bash
(然后运行 python
)。尝试使用参数 ["python", "$file"]
将命令设置为 bash
。
关于python - 配置 Visual Studio Code 以在 Windows 上的 bash 中运行 Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39751858/