Visual Studio code Debugger won’t start on my Python - 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

Related

my code is not showing is the terminal and there is no error

I was trying to run a code in vs code but the code didn't run and there is no error showing in the terminal. I made a new file and then tried to run a "Hello World!" but the code didn't run too. I uninstalled and re-installed vs code (three times) but that didn't work.
And when I say that there is no error showing I mean it. whenever I run the code nothing happens and vs code doesn't even give a hint or a sign that the code got executed or not.
First, you should understand that vscode is a lightweight editing
tool. If you want to run python files, first make sure you have
installed python correctly. You can enter command python --version
in the terminal to confirm it.
Then, please install python extension in the vscode extension store.
Then use shortcuts "Ctrl+Shift+P" and type "Python: Select
Interpreter" to choose the python interpreter.
Finally, creat *.py file and run it.
Read this docs for more details which can help you get started faster.

Running Python in VS Code Terminal

Im really quite new to coding and brand new to Python so apologies if this is a dumb question.
I'm writing basic scripts in VS Code and when I run them the result in the terminal is just..... ugly. Instead of just printing the result of my code, it prints details about my version of Windows, a little copyright notice, the full file path to my code... then eventually gets round to executing my actual code.
Is there any way for me to configure the terminal so that it just shows my code and not all the other bits? I've already seem about an extension called Code Runner, but this prints to the "Output" tab and doesn't allow any user input
If you are using PowerShell, you can add "args": ["-NoLogo"], like this to Hides the copyright banner at startup :
  "terminal.integrated.defaultProfile.windows": "PowerShell",
  "terminal.integrated.profiles.windows": {
    "PowerShell": {
      "source": "PowerShell",
      "icon": "terminal-powershell",
      "path": ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"],
      "args": ["-NoLogo"],
    }
  },
And you also can change the value of console in the launch.json file. But internalConsole does not accept the user input. And externalTerminal will prompt a cmd window out of the VSCode.
Maybe you can try Jupyter code cells:
https://code.visualstudio.com/docs/python/jupyter-support-py
Try jupyter on visual studio code interface
https://code.visualstudio.com/docs/datascience/jupyter-notebooks
You have to follow these steps:
install python extension for vs code.
python extension
2.After installing reopen vs code and you will see a play button at right-top corner.
play button
3.Click that button and run your code!
go to settings
search for terminal
find Code-runner : Run in Terminal and turn that off.

VS Code had a problem in running the code

I tried to run a python program in VS Code. But my program didn't run. The terminal opened and a weird arrow was there in the terminal. This is the screenshot of that.
This is the weird arrow and the program is not running. Any ideas why this is happening and how to fix it?
Thanks in advance.
Firstly, the arrows are included in the default python IDE means that VScode ran the command to execute your code. Give your pc a restart. Now, let us check if python is working or not or VS code is having some trouble. Type the following command in cmd to execute the code-
python "$PATH"
Rember to replace $PATH to the path of the file i.e where your file is stored. For eg. I've my python files stored in D drive in a python folder, so I'll use-
python "D:\Python\Hello.py"
If this works, python is working fine and if not, try reinstalling python and check the box which says Add python to Path or Environment variables. Then open VS code try to run the program again. But click the button only once and be patient because clicking it multiple times causes execute the same command again and cause a problem. It's my personal experience. Wait 5 minutes. Not works. Don't worry, there's a problem with the run extension you are using. I'll recommend the Code runner by Jun han. I personally use it. Type this in the extension search box-
formulahendry.code-runner
Install it and then try again.
Kill the terminal, and retry. If not work, restart the VSCode.

Issue with VS Code and python preview extension

im new using VS Code, and im not able to get to work a plugin called "Python preview"
Im using Ubuntu 20.04 and VS code 1.46.1.
When i try to "open preview on the side" of any .py file, its tries to open but close suddenly raising always this issue:
"Failed to launch the Python Process, please validate the path 'python'"
I suspect that this might happen with other extensions.
Any idea?
I had the same problem. Follow these steps and it will be OK:
How To Install Anaconda on Ubuntu
reload the vs code
try python preview in vs code

Running Python in Visual Studio 2017, output not showing correctly?

I was using a different IDE for running Python scripts, but I would like to switch over to Visual Studio. When I try testing simple scripts that work in the simple IDE, I can't figure out how to get my output to show correctly. I have tried running the debugger, pressing CTRL+F5, and pressing CTRL+F5 then CTRL+d, but all that happens is that a blank console pups up, and the cursor blinks actively.
I have run out of ways to rephrase this issue to get something helpful to show up in both Google search results and in StackOverflow. The main results I get are about antivirus software (thoroughly investigated, not the problem here) and articles about beginning Python in VS. How do I get my Python programs to show output correctly? And also am I using incorrect terminology?
What happens when I hit Ctrl+F5
Have you already gone through the Installation, Quickstarts and Tutorials here:
https://learn.microsoft.com/en-us/visualstudio/python/overview-of-python-tools-for-visual-studio
Make sure the simple hello_world.py file with one line works:
print("Hello World")
If you still have problems, it may be that Visual Studio does not realize you have Python installed (i.e. if python is not in your path variables).

Categories