I am really new to Python and just started the course "Python 3 basics by Sendtex (Link: https://www.youtube.com/channel/UCfzlCWGWYyIQ0aLC5w48gBQ)".
However, I am not able to get any output. Below is the attached screenshot.
If I select Python it enters debugging mode. So, there isn't any output.
python hello.py
and press Enter. This should run the code and show an Output. I recommend reviewing the official Visual Studio Code Python documentation and tutorial. That provides several of the basics, with running and debugging the "official" way.
There are multiple ways to configure built-in launches:
You can run or debug using an icon and dropdown in the upper right of your editor window, when editing a python script file.
You may need to setup a run/debug configuration to use this (see below), or it may automatically step you through creating one.
The output will normally go to a new "Python" terminal in the "terminal" window (Ctrl-` to open it). See this answer for how to change that behavior.
Run/Add Configuration
, and follow the prompts at the top of the VS Code window.Updated Image (1/2022) - Changed from just 'Debug' to 'Run and Debug':
Now your debug configuration box on the top left of the debug pane should say "Python: Current File":
Visual Studio Code will add a file to your current workspace or working folder called .vscode/launch.json
, and opened it for edit.
python my_script.py
command.
cd
commands, etc.), or add the absolute or relative folder path to the name of the script.python
command may be python2
or python3
on some installs (usually linux), and can be just py
for the Python Launcher on Windows (auto-installs with Python).During installation if you forget to tick in check box for path
and then if you are running any python file on visual studio it will not return any output
untill and unless you have not added it into visual studio code
.
First of all go to File
→ Preference
→ Settings.json
"code-runner.executorMap":
{
"python": "\"C:\\Program Files\\Python39\\python.exe\""
I have attached the screenshot for your better understanding!
I had the same problem, but figured that close to top right of your Visual Studio Code there is a little green triangle saying "running code in Terminal". I you wanted to see some kind of print('Hello') it is does the job.
I ended up scrapping code and moving my project to Visual Studio 19. Works just fine now. Prints show up in a command prompt.
I found this post when trying to find how to show my python code output in the VSCode output window instead of the integrated terminal window. In my case the problem was caused by a Code-runner setting. Here's how I fixed my problem :
CTRL
+ SHIFT
+ P
).Preferences : Open Settings (UI)
.Code Runner : Run in Terminal
.
Now when you select Run Code
(or CTRL
+ ALT
+ N
) option when running your code, the Output window should work.
read-only
. My method is not suitable if you are taking input from user.