简体   繁体   中英

Debugging Python in VS Code in Windows

I have VS Code installed on my Windows machine with the Python extension. I have also installed Windows Sub-system for Linux (Ubuntu) so I have the Bash shell available. I am experimenting with combining VS Code on Windows. In VS Code, I have set my default terminal to Bash (WSL.exe). The code is very simple for testing:

msg = "Hello World"
pring(msg)

I set my breakpoint on the second line so that I can see code executing. When I launch the debugger however, the debugger does not work. Here is the output in the terminal:

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

As you can see above, Bash is having trouble concatenating the path. When I switch my default terminal to the either the PowerShell or DOS, the debugger launches correctly.

I am more used to the Bash prompt having used Mac and Linux for a long time. Now that I have to use Windows, I was trying to combine VS Code on windows side to use the Linux Subsystems's Bash shell.

The debugger has stopped me however. Is there a way to fix this?

Thanks.

VS Code的Python扩展尚不支持WSL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM