Reputation: 472
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.
Upvotes: 25
Views: 153992
Reputation: 1
After writing your code, press ctrl+s in vscode to save it. then you can run your code and the result will be displayed. My problem solved this way.
I hope it helps you too
Upvotes: 0
Reputation: 11719
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 the "triangle" icon and dropdown in the upper right of your editor window, when the editor window is focused on a python script file (i.e. typically a file named *.py).
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.
Upvotes: 9
Reputation: 11719
Open a terminal in VS Code (View/Terminal in menu or Ctrl-`, which is the "Ctrl" key and the "Grave" or "Tick-mark" key, normally at the top left of keyboard above tab).
Run the python script in the current directory with a simple python my_script.py
command.
cd
commands, etc.), or add the absolute or relative folder path to the name of the script.The output will show up in the same terminal.
python
command may be python2
or python3
on some installs (usually linux), and can be just py
for the Python Launcher (auto-installs with typical Python for Windows installs).Upvotes: 4
Reputation: 1945
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.Upvotes: 2
Reputation: 1123
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!
Upvotes: 2
Reputation: 5
I ended up scrapping code and moving my project to Visual Studio 19. Works just fine now. Prints show up in a command prompt.
Upvotes: -2
Reputation: 1
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.
Upvotes: -1