在 Windows 的 VS Code 中调试 Python
Debugging Python in VS Code in Windows
我的 Windows 机器上安装了 VS Code,扩展名为 Python。我还为 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 时,调试器会正确启动。
我比较习惯Bash提示,长期使用Mac和Linux。现在我必须使用 Windows,我试图在 windows 端结合 VS Code 以使用 Linux 子系统的 Bash shell.
但是调试器阻止了我。有办法解决这个问题吗?
谢谢。
VS Code does not support WSL yet 的 Python 扩展。
我的 Windows 机器上安装了 VS Code,扩展名为 Python。我还为 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 时,调试器会正确启动。
我比较习惯Bash提示,长期使用Mac和Linux。现在我必须使用 Windows,我试图在 windows 端结合 VS Code 以使用 Linux 子系统的 Bash shell.
但是调试器阻止了我。有办法解决这个问题吗?
谢谢。
VS Code does not support WSL yet 的 Python 扩展。