🌐
Python
python.org › shell
Welcome to Python.org
Whether you're new to programming or an experienced developer, it's easy to learn and use Python.
Downloads
The official home of the Python Programming Language
Macos
The official home of the Python Programming Language
Windows
The official home of the Python Programming Language
Getting Started
The official home of the Python Programming Language
🌐
Python.org
discuss.python.org › python help
How to run Python Terminal - Python Help - Discussions on Python.org
December 17, 2024 - I am using Windows operating machine. In start menu I found “Python 3.12.7 (64 bit)” But when I type python-v I am not able to get the python version. I think I am missing packages maybe. Kindly have a look at the atta…
Discussions

I don't understand the differences between Terminal/Shell/Interpreter/Command Prompt
Terminal and command prompt are the same thing. "Terminal" is the usual word in a Linux/Mac context, and "command prompt" on Windows. It's the window where you type in commands to your operating system to run programs, etc. The Python interpreter is a program which reads Python code and runs it. Python code is just text, which your computer can't run natively. Hence, it needs an interpreter. This would be your python.exe (on Windows). If you just run the interpreter alone, without specifying a file with code for it to run, it operates as an interactive shell for you to type in Python code line by line and see it execute immediately. This is particularly useful for trying out small pieces of code to see how it works. An IDE is an "integrated development environment". It's a fancy editor with features specifically to help with coding. The standard Python installation comes with a simple IDE called IDLE to get you started. More on reddit.com
🌐 r/learnpython
23
67
July 29, 2021
command line - Creating a Terminal Program with Python - Stack Overflow
I recently started learning python. I have created some basic webapps with Django and wrote some simple scripts. After using VIM as a Python IDE I really fell I love with "Terminal programs" (is th... More on stackoverflow.com
🌐 stackoverflow.com
Why does anyone run python in the terminal?
For one thing, that lets you continue editing the code while seeing the output of the previous run in another window. More on reddit.com
🌐 r/learnpython
23
0
June 30, 2021
macos - How to run Python script on terminal? - Stack Overflow
I want to run a Python script in Terminal, but I don't know how? I already have a saved file called gameover.py in the directory "/User/luca/Documents/python". More on stackoverflow.com
🌐 stackoverflow.com
🌐
vteams
vteams.com › blog › how-to-run-a-python-script-in-terminal
How to Run a Python Script in Terminal Step by Step Guide
April 7, 2025 - Use the cd (change directory) command to navigate to the directory where your Python script is located. For example, if your script is in a folder called “my_python_scripts,” you can navigate to it like this while learning how to run a python script in terminal
🌐
Real Python
realpython.com › run-python-scripts
How to Run Your Python Scripts and Code – Real Python
1 month ago - The python command’s -m option runs Python modules by searching sys.path rather than requiring file paths. IDEs like PyCharm and code editors like Visual Studio Code provide built-in options to run scripts from the environment interface. To get the most out of this tutorial, you should know the basics of working with your operating system’s terminal ...
🌐
CodingNomads
codingnomads.com › how-to-use-the-python-terminal
How to Use the Python Terminal
Using the interactive mode, you can execute Python code line by line. As you can imagine, this approach is slightly limited: once your current session is terminated, your work is lost forever.
🌐
Real Python
realpython.com › terminal-commands
The Terminal: First Steps and Useful Commands for Python Developers – Real Python
February 2, 2026 - Learn your way around the Python terminal. You’ll practice basic commands, activate virtual environments, install packages with pip, and keep track of your code using Git.
🌐
Reddit
reddit.com › r/learnpython › i don't understand the differences between terminal/shell/interpreter/command prompt
r/learnpython on Reddit: I don't understand the differences between Terminal/Shell/Interpreter/Command Prompt
July 29, 2021 -

Lots of terminology flying around about the environment within which python can be run - could someone please explain like I'm five?

Edit: Also where does IDE fit in? How do you interact with python through an IDE and how does it differ

Top answer
1 of 5
69
Terminal and command prompt are the same thing. "Terminal" is the usual word in a Linux/Mac context, and "command prompt" on Windows. It's the window where you type in commands to your operating system to run programs, etc. The Python interpreter is a program which reads Python code and runs it. Python code is just text, which your computer can't run natively. Hence, it needs an interpreter. This would be your python.exe (on Windows). If you just run the interpreter alone, without specifying a file with code for it to run, it operates as an interactive shell for you to type in Python code line by line and see it execute immediately. This is particularly useful for trying out small pieces of code to see how it works. An IDE is an "integrated development environment". It's a fancy editor with features specifically to help with coding. The standard Python installation comes with a simple IDE called IDLE to get you started.
2 of 5
29
Terminal: Physical device (nowadays rare) or graphical program (there also called terminal emulator), that transfers keyboard input to a dedicated program in text form and displays that programs textual output. Usually, the dedicated program is a shell in interactive mode. Interpreter: A program that receives a series of instructions and performs the associated actions and computations immediately. The interpreter can either read the instructions from file or read them interactively by requesting new input after each instruction. Shell / command interpreter: Special interpreter that can perform basic system actions like selecting a working directory and calling other programs. This is often generally done interactively. Command promt: A special symbol displayed by the shell in the terminal to signal that it is awaiting inputs. In Unix, opening a shell or opening a terminal usually mean the same thing: When a terminal emulator is lauched it will usually start and connect a shell. When a shell is openend, it will either use the terminal of the parent program, or if launched from a gui, a terminal will be opened to display it's output. In Windows the term command interpreter is prefered over shell and the whole thing is often referred to as command prompt.
Find elsewhere
🌐
OpenTechSchool
opentechschool.github.io › python-beginners › en › getting_started.html
Getting started — Introduction to Programming with Python
There are in fact many ways to do this; the first one to learn is to interact with python’s interpreter, using your operating system’s (OS) console. A console (or ‘terminal’, or ‘command prompt’) is a textual way to interact with your OS, just as the ‘desktop’, in conjunction ...
🌐
Pyscript
docs.pyscript.net › 2024.1.1 › user-guide › terminal
Python terminal - PyScript
It's to the terminal that print writes characters (via stdout), and it's from the terminal that the input reads characters (via stdin).
🌐
GeeksforGeeks
geeksforgeeks.org › python › open-and-run-python-files-in-the-terminal
Open and Run Python Files in the Terminal - GeeksforGeeks
July 23, 2025 - The Linux terminal offers a powerful environment for working with Python files, providing developers with efficient ways to open, edit, and run Python scripts directly from the command line.
🌐
Python
docs.python.org › 3 › using › cmdline.html
1. Command line and environment — Python 3.14.3 documentation
Ignore all PYTHON* environment variables, e.g. PYTHONPATH and PYTHONHOME, that might be set. See also the -P and -I (isolated) options. ... Enter interactive mode after execution. Using the -i option will enter interactive mode in any of the following circumstances: ... Interactive mode will start even when sys.stdin does not appear to be a terminal.
🌐
OneCompiler
onecompiler.com › python
Python Online Compiler & Interpreter
OneCompiler's python online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab.
🌐
Digis
digiscorp.com › how-to-run-python-file-in-terminal
How to Run Python File in Terminal? - Digis
July 29, 2025 - Learn how to run a Python file in the terminal with this step-by-step guide. From setup to troubleshooting, discover tips for running Python scripts efficiently. Perfect for beginners and developers!
Top answer
1 of 5
32

On a *nix system (linux/unix),
if you:

$ chmod 0744 your_file.py

-rwxr--r--   your_file.py

and add the path to python as the first line of your_file.py:

#!/usr/bin/python

or (in my case):

#!/usr/local/bin/python

Once you do that, instead of running it like this:

$ python your_file.py

You can run it like this:

$ ./your_file.py

or even rename it to yourfile and run it like this:

$ ./yourfile

and if you then copy yourfile to your bin (i.e. #!/usr/bin/, or #!/usr/local/bin/) you can run it like this:

$ yourfile

Then you can...

Use raw_input() to solicit and get input from you user.

your_file.py:

#!/usr/local/bin/python

import os

while(True):
    # cntrl-c to quit
    input = raw_input('your_prompt$ ')
    input = input.split()
    if input[0] == 'ls':
        dire = '.'
        if len(input) > 1:
            dire = input[1]
        print('\n'.join(os.listdir(dire)))
    else:
        print('error')

your_file.py use example:

$ chmod 744 your_file.py 
$ cp your_file.py /usr/local/bin/your_file 
$ your_file 
your_prompt$ ls
list_argv.py
your_file.py
your_ls.py
your_subprocess.py
your_prompt$ ls .
list_argv.py
your_file.py
your_ls.py
your_subprocess.py
your_prompt$ pwd
error
your_prompt$ ^CTraceback (most recent call last):
  File "/usr/local/bin/your_file", line 7, in <module>
    input = raw_input('your_prompt$ ')
KeyboardInterrupt
$

Grab arguments with sys.argv from the command line when you run your script:

list_argv.py:

#!/usr/local/bin/python

import sys

print(sys.argv)

list_argv.py use example:

$ python list_argv.py 
['list_argv.py']
$ python list_argv.py hello
['list_argv.py', 'hello']
$ python list_argv.py hey yo
['list_argv.py', 'hey', 'yo']

$ chmod 744 list_argv.py 
$ ./list_argv.py 
['./list_argv.py']
$ ./list_argv.py hi
['./list_argv.py', 'hi']
$ ./list_argv.py hey yo
['./list_argv.py', 'hey', 'yo']

$ cp list_argv.py /usr/local/bin/list_argv
$ list_argv hey yo
['/usr/local/bin/list_argv', 'hey', 'yo']

Replace raw_input() with sys.argv.

'your_ls.py':

#!/usr/local/bin/python

import sys
import os

dire = '.'
if len(sys.argv) > 1:
    dire = sys.argv[1]
print('\n'.join(os.listdir(dire)))

'your_ls.py' use example:

$ chmod 744 your_ls.py 
$ cp your_ls.py /usr/local/bin/your_ls
$ your_ls 
list_argv.py
your_file.py
your_ls.py
your_subprocess.py
$ your_ls .
list_argv.py
your_file.py
your_ls.py
your_subprocess.py
$ your_ls blah
Traceback (most recent call last):
  File "/usr/local/bin/your_ls", line 9, in <module>
    print('\n'.join(os.listdir(dire)))
OSError: [Errno 2] No such file or directory: 'blah'

Use subprocess.Popen to access anything you could from the command line.

your_subprocess.py:

#!/usr/local/bin/python

import os
import subprocess

while(True):
    # cntrl-c to quit
    input = raw_input('your_prompt$ ')

    process = subprocess.Popen(input, shell=True,
                           stdout=subprocess.PIPE,
                           stderr=subprocess.PIPE)

    out, err = process.communicate()

    print(out)
    print(err)

your_subprocess.py use example:

$ chmod 744 your_subprocess.py 
$ cp your_subprocess.py /usr/local/bin/your_subprocess
$ your_subprocess 
your_prompt$ ls
list_argv.py
your_file.py
your_ls.py
your_subprocess.py


your_prompt$ ls .
list_argv.py
your_file.py
your_ls.py
your_subprocess.py


your_prompt$ pwd
/Users/ox/_workspace/cmd_ln


your_prompt$ blah

/bin/sh: blah: command not found

your_prompt$ ^CTraceback (most recent call last):
  File "/usr/local/bin/your_subprocess", line 8, in <module>
    input = raw_input('your_prompt$ ')
KeyboardInterrupt
$

BREAK STUFF!

:-D

HAVE FUN!

-ox

2 of 5
21

A true command-line program is something in the vein of ls or grep; it is started from the command-line, but it's non-interactive and can be used in pipelines and combined with other command-line programs. A typical command-line program is not interactive on its own, instead relying on shell for interaction, and on an init file for customization.

What you want to create is a TUI (text user interface) application, that uses the full capabilities of the TTY as an interactive platform. To do that, look up curses.

🌐
Microsoft Learn
learn.microsoft.com › en-us › windows › dev-environment › python
Python on Windows for beginners | Microsoft Learn
1 month ago - Python extension for Visual Studio Code – Adds Python language support, debugging, linting, and more ... The WinGet configuration file below installs everything listed above automatically. ... When the configuration starts, a terminal window shows the setup steps and required installs.
🌐
FavTutor
favtutor.com › blogs › run-python-file-terminal
How to Run a Python File in Terminal? (Step-by-Step)
November 14, 2023 - The PVM is responsible for running the bytecode and producing the desired output. This is how you can read a python file line by line. A terminal or command-line interface is a text-based interface through which one can perform commands using the operating system’s shell.