【问题标题】:Debugging Python in VS Code in Windows在 Windows 的 VS Code 中调试 Python
【发布时间】:2018-09-26 16:25:50
【问题描述】:

我在我的 Windows 机器上安装了带有 Python 扩展的 VS Code。我还安装了适用于 Linux (Ubuntu) 的 Windows 子系统,因此我可以使用 Bash shell。我正在尝试在 Windows 上组合 VS Code。在 VS Code 中,我已将默认终端设置为 Bash (WSL.exe)。测试代码非常简单:

msg = "Hello World"
pring(msg)

我在第二行设置了断点,这样我就可以看到代码正在执行。但是,当我启动调试器时,调试器不起作用。这是终端中的输出:

bruparel@WIN-XPI7AFTJ1F:/mnt/c/Users/bharat.c.ruparel/py_work$ cd c:\Users\bharat.c.ruparel\py_work && cmd /C "set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && set "PYTHONPATH=c:\Users\bharat.c.ruparel\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd" && C:\Users\bharat.c.ruparel\AppData\Local\Continuum\anaconda3\python.exe -m ptvsd --host localhost --port 58124 c:\Users\bharat.c.ruparel\py_work\hello_world.py "
-bash: cd: c:Usersbharat.c.ruparelpy_work: No such file or directory

正如您在上面看到的,Bash 无法连接路径。当我将默认终端切换到 PowerShell 或 DOS 时,调试器会正确启动。

我比较习惯使用 Mac 和 Linux 很长时间的 Bash 提示符。现在我必须使用 Windows,我试图在 Windows 端结合 VS Code 以使用 Linux 子系统的 Bash shell。

然而,调试器阻止了我。有没有办法解决这个问题?

谢谢。

【问题讨论】:

  • 从windows子系统for linux,你在/mnt/c而不是c:\Users访问windows机器的C:驱动器
  • 我知道。我的问题是如何调整 VS Code 调试器设置,以便 Linux 端的 Python 执行/启动我的调试代码。我在 linux 端和 windows 端的 Windows 子系统上都安装了相同版本的 Anaconda。

标签: python bash debugging visual-studio-code windows-subsystem-for-linux


【解决方案1】:

VS Code 的 Python 扩展 does not support WSL yet

【讨论】:

    猜你喜欢
    • 2020-09-30
    • 1970-01-01
    • 2020-07-12
    • 2021-06-20
    • 2019-12-29
    • 2020-04-06
    • 2021-03-17
    • 2020-12-16
    相关资源
    最近更新 更多