gpt4 book ai didi

python - 配置 Visual Studio Code 以在 Windows 上的 bash 中运行 Python

转载 作者:太空狗 更新时间:2023-10-29 21:59:22 25 4
gpt4 key购买 nike

我想使用 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}"]
}
]
}

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

  1. 任务没有按照我的意愿在 bash 中运行
  2. 访问 C 驱动器 I need to replace C:\ 文件路径为 /mnt/c

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

最佳答案

我没有带 bash 的 Windows 10,但我想问题在于您实际上并没有尝试运行 Python。您正在尝试运行 bash(然后运行 ​​python)。尝试使用参数 ["py​​thon", "$file"] 将命令设置为 bash

关于python - 配置 Visual Studio Code 以在 Windows 上的 bash 中运行 Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39751858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com