简体   繁体   中英

Visual Studio code Debugger won’t start on my Python

I have a very simple program written but when I click start on the Visual Studio debugger nothing happens! Sorry total noob here. Working with python 3.6.5 32 bit for Windows. The program runs from the terminal just fine.

def main():  
  print ("hello world!")

if __name__ == "__main__":  
  main()

I've just come across the same issue in VS Code (I think) in that I can run a one line python file from the terminal and it will work as expected:

python HelloWorld.py

However when I try to run it in the debugger nothing happens other than the Debug toolbar briefly appearing. I got more suspicious having put a junk console entry in launch.json and it didn't cause any errors.

My problem was that the training instructions I'm following told me to set the following for my workspace settings so it would use the specific python executable in my virtual environment:

{
    "python.pythonPath": "env\\Scripts\\python"
}

Once I changed the last part of that path to python.exe , everything worked as expected. Hopefully you can try a similar resolution in Visual Studio.

I had the same issue with all ide programs not just VS.code the problem is when installing python you didn't allow different ide environments to use python and its only executable from windows terminal what you need to do is delete python and VS code completely then again install python 3.x and in the first page of installation check the "Add python to path" box its a must if you want to use something other than windows terminal to code. after reinstalling the python now reset your device and install VS code again and that's it. problem solved

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