我在 Windows 10 上以 WSL bash 作为终端运行 Visual Studio Code:
"terminal.integrated.shell.windows": "C:/Windows/sysnative/bash.exe"
在 WSL bash 中,我同时安装了 python
(v2.7) 和 python3
(v3.6)。
我已经为 VS Code 安装了 Python 扩展。不幸的是,VS Code 无法在 WSL bash 中识别任一版本的 Python。
例如,当我尝试发现测试时,我在 Python 测试日志输出窗口中收到以下错误:
Test Discovery failed:
Error: spawn python ENOENT
如何配置 VS Code 以使用 Python 形式的 WSL bash?
注意:我很确定我需要在 VS Code 用户设置文件的 "python.pythonPath"
键中配置 Python 的路径。不过,我不确定将哪条路径作为值。
最佳答案
对 WSL 的支持是通过“WSL - Remote”扩展完成的。有一个 WSL blog post其中包括如何开始。
关于python - 为什么 Visual Studio Code 无法识别我的 WSL bash python?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48524846/