If you are using the CLI, (command line interface), that is, the text terminal in Ubuntu Linux, be sure you are actually running Python interpreter within your CLI.

From the command prompt $, type "python" or perhaps "python3". That should get you a python prompt that looks like this: >>>. That will be where you enter your commands into the python interpreter.

From the python prompt >>> you can type your simple commands.

If you are saving these to a program/script as a .py file, then to run the script you would need to type "python ./hello.py", in order to recruit the python interpreter to run the script.

If you are using a specific development environment (IDE), like VS Code, Eclipe, or PyCharm, or some other, let us know. These are special programs for writing code where you type and save your file in a window within the program. These have their own processes for running the program from the IDE. Most will have a play button somewhere to run the script and give output in a separate pane, e.g., near the bottom of the window as in VS Code.

Answer from Eric on askubuntu.com
🌐
Reddit
reddit.com › r/learnpython › python not working- not displaying an output.
r/learnpython on Reddit: Python not working- not displaying an output.
May 25, 2024 -

So I have a file named main.py, in it there is just a basic print("Hello world")

I tried running it but it shows no output, both in vsc code runner and by running through a terminal. I thought something was wrong with my code, but it ran in some online ide. How do I fix my python? when i did py --version it shows Python 3.12.3. Ive added it to the path, i really dont know what to do.

Thanks for help:)

🌐
Sublime Forum
forum.sublimetext.com › t › build-of-python-code-not-showing-output › 63676
Build of python code not showing output - Technical Support - Sublime Forum
April 19, 2022 - Hello, I hope this isn’t a stupid question/issue, newbie to sublime. this was all working yesterday and now if I run the following simple python code (file is test1.py) print(‘Hello’) I get Hello execution time if I add a second print line, as follows: print(‘Hello’) print(‘Goodbye’) I only get the execution time, no print, anything more than 1 line shows just the execution time.
🌐
GitHub
github.com › Microsoft › PTVS › issues › 1704
Python program not showing result or output in Windows console · Issue #1704 · microsoft/PTVS
October 8, 2016 - I am new to python tools for visual studio and need help. I tried to run a simple "Hello World" code but cannot see its output. To give the details regarding the problem I have created a short video showing the issue while executing the ...
Author   shatir
🌐
Reddit
reddit.com › r/pythonlearning › python output not showing up when i run it.
r/PythonLearning on Reddit: Python output not showing up when I run it.
January 12, 2025 -

I am very new to python so it is probably a very easy fix but when I try to run a very simple code such as print("Hello World") there is no output in the terminal. Not even an error message. I have already checked and the latest version of python is installed on my PC. I made a file yesterday off of the notepad browser titled "Helloworld.py" and it worked perfectley fine. I open the the file "Helloworld.py in visual studio world today but no output is occuring? Can someone please help me?

🌐
ShellHacks
shellhacks.com › home › python script not showing output [solved]
Python Script Not Showing Output [SOLVED] - ShellHacks
August 10, 2022 - Debug a Python script that hangs and doesn't print anything to a terminal by forcing the `stdout` and `stderr` streams to be unbuffered (PYTHONUNBUFFERED).
🌐
Python.org
discuss.python.org › python help
No output main() issue? - Python Help - Discussions on Python.org
March 4, 2024 - Hello. I am new to python and working on a lab assignment that I am trying to run in Python. The issue is that I am getting no output even though I have followed the code multiple times. I tried to run this code, and I am expecting the following output. I am getting no prompts or output when ...
Find elsewhere
🌐
Codecademy Forums
discuss.codecademy.com › data science
Why is there no output in the terminal? - Data Science - Codecademy Forums
March 18, 2019 - why is my terminal in the code academy going blank, when I press next after doing python
🌐
Python.org
discuss.python.org › python help
Python not printing - Python Help - Discussions on Python.org
August 24, 2021 - Hi I’m trying make a code where it prints the last lines of a file, and when i run the code, it runs fine but no output shows. I’m using the readline() command. Here is the code: with open(“MergeFiles.txt”) as File1: print("How many lines do you have?") File1Len = len(File1.readlines()) print("File 1 has: "+str(File1Len)+" Lines") print("File 1's last line is: "+File1.read(File1Len)) File1.flush() File1.close() with open ("MergeFiles2.txt") as File2: File2Len = len(File2.readlines(...
🌐
freeCodeCamp
forum.freecodecamp.org › python
Python code not printing output - Python - The freeCodeCamp Forum
November 19, 2016 - # your code goes here def calculate(m,n): result = m * n return result print result calculate(2,3) This is python code and there is proper indentation in it ,as have tried to put it here also but editor is not supporting .Any way it is running successfully over my editor but it is not printing ...
Top answer
1 of 8
9

Using the Python Extension Run/Debug commands

Notes

  1. 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.

  2. There are multiple ways to configure built-in launches:

    • When running or debugging Python in VS Code, there are a few options that you can change in your "launch.json" file. See this answer for more details.

Run or Debug with the built-in Python extension commands

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.


Setting up a run/debug configuration

Easy option:

  • Use the menu item **Run/Add Configuration, and follow the prompts at the top of the VS Code window.
  • Some of the additional details are shown below.

More involved option:

  • Click the run/debug icon on the left vertical icon toolbar.
  • The window says "RUN AND DEBUG" at the top, with a drop-down that shows "No Configurations" for a given folder or workspace until you set this up.
  • The gear to the right of the dropdown will have a red dot if you need to configure this:

Updated Image (1/2022) - Changed from just 'Debug' to 'Run and Debug':

  • Click the gear icon (or in the menu, use Run/Open Configurations), and in the middle at the top, Visual Studio Code will open a window titled "Select a debug configuration".
    • The available options will depend on exactly how you have Visual Studio Code setup and configured
    • There should at least be a "Python File" option with the Python extension installed. Select it.

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.

2 of 8
4

Simplest Answer: Run the file directly in a terminal

  1. 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).

    • This will open the terminal to the root of the folder VS Code has open (the one that shows up in the Explorer sidebar - Ctrl-Shift-E to see).
  2. Run the python script in the current directory with a simple python my_script.py command.

    • If the script is in another directory than the root of the current workspace or folder you opened the terminal in, you will need to change to that directory (using cd commands, etc.), or add the absolute or relative folder path to the name of the script.
  3. The output will show up in the same terminal.

Notes

  • You must have a python executable on your path, be in an active virtual environment, or give the full path to the python executable.
  • Your 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).
  • This option will not use any 'launch.json' configurations, and cannot be easily used to debug with.
  • You can configure the default terminal that is used, such as Git Bash, CMD, or Powershell (on Windows). You can also open additional terminal windows of any configured type using the "+" icon and it's dropdown, in the terminal window.
🌐
GitHub
github.com › rundeck › rundeck › issues › 885
output of python shows up only at the end of the execution · Issue #885 · rundeck/rundeck
August 4, 2014 - print statements in a python script are not showing up synchronously (when they are run from the script) but they show up together when the script ends its execution. I could try to replace "print" with "sys.stdout.write", but it makes n...
Author   maxadamo
🌐
Sololearn
sololearn.com › en › Discuss › 2214395 › no-output-in-python
No output in python? | Sololearn: Learn to code for FREE!
Simply write, print(functionname()) if 'a' is the parameter inside so u can pass the input like, print(functionname("habzhshanzbhsjanahshsjah") You should have RETURNS instead of PRINTS inside ur function, otherwise they can return an output ...
🌐
Code with Mosh
forum.codewithmosh.com › python
Output window not giving output - Python - Code with Mosh Forum
May 4, 2022 - I had format my laptop than install python and visual studio code again and even install code runner which was suggested by mosh…still i am not getting output in output terminal , but when i run same code in terminal win…
🌐
Python Forum
python-forum.io › thread-31997.html
Print output not working
January 14, 2021 - Dear All, i started studying python and i have been facing some issues with command print. I will do an exaple: >>>print=('Hello World') + inv >>>When i put the above command in the idle i do not get the output string which should...
🌐
Code with Mosh
forum.codewithmosh.com › python
No error but still no output - Python - Code with Mosh Forum
April 22, 2021 - Why can’t this run and give a pattern output, please help. I am a beginner. def pattern(n): k = 2 * n - 2 for i in range(0,n): for j in range(0,k): print(end=" ") k = k-1 for j in range(0…
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 2029227 › how-to-see-the-output-of-my-python-code-in-visual
How to see the output of my python code in visual studio code - Microsoft Q&A
August 30, 2024 - You can use it to step through your code line by line and observe the output. To start the debugger: Click on the "Run" menu and choose "Start Debugging" or press F5. Add breakpoints in your code by clicking on the left margin next to the line number. This will help you see exactly where the code is stopping or not executing. 6.Check Python Installation in VS Code: Ensure your Python environment is set up correctly.