When it comes to programming, there are kind of three debatable levels of code: source code, byte code, and machine code. Humans usually write source code, the source code gets compiled into byte code, and then byte code gets compiled into machine code. In languages like C and C++, the byte code portion is kind of hidden away as compilers like GCC will output machine code from source code. Newer compilers like LLVM introduce the concept of byte code but that's out of scope for your question. Languages like Java (and things that use LLVM) compile your source code into byte code which is then executed at runtime in a virtual machine which converts it to machine code. Languages like Python skip all compilation and the interpreter translates source code into machine code at runtime. This is only half true as *.pyc files are actually compiled byte code but these aren't usually exposed directly to a user. EDIT: My second note about LLVM was poorly worded and thus misleading. Answer from Caligatio on reddit.com
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ online-compiler
Online Python Compiler (Interpreter) - Programiz
3 weeks ago - # Online Python compiler (interpreter) to run Python online. # Write Python 3 code in this online editor and run it.
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ tutorial โ€บ interpreter.html
2. Using the Python Interpreter โ€” Python 3.14.2 documentation
Invoking the Interpreter: The Python interpreter is usually installed as/usr/local/bin/python3.14 on those machines where it is available; putting/usr/local/bin in your Unix shellโ€™s search path mak...
Discussions

What does a Python interpreter do?
When it comes to programming, there are kind of three debatable levels of code: source code, byte code, and machine code. Humans usually write source code, the source code gets compiled into byte code, and then byte code gets compiled into machine code. In languages like C and C++, the byte code portion is kind of hidden away as compilers like GCC will output machine code from source code. Newer compilers like LLVM introduce the concept of byte code but that's out of scope for your question. Languages like Java (and things that use LLVM) compile your source code into byte code which is then executed at runtime in a virtual machine which converts it to machine code. Languages like Python skip all compilation and the interpreter translates source code into machine code at runtime. This is only half true as *.pyc files are actually compiled byte code but these aren't usually exposed directly to a user. EDIT: My second note about LLVM was poorly worded and thus misleading. More on reddit.com
๐ŸŒ r/learnpython
38
194
November 28, 2020
Is Python interpreted, or compiled, or both? - Stack Overflow
From my understanding: An interpreted language is a high-level language run and executed by an interpreter (a program which converts the high-level language to machine code and then executing) on ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
visual studio code - Selecting python interpreter in VSCode - Stack Overflow
I am using VSCode with ArcGIS Pro 3.0 in a virtual environment. Until yesterday, everything worked just fine. After updating to Pro 3.0, I was still able to use open a script and then have it run i... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Updating Python interpreter over and over : pycharm
this process is in the loop: scanning files to index... discovering binary modules... scanning installed packages... (there's 1-2 more steps... More on old.reddit.com
๐ŸŒ r/pycharm
๐ŸŒ
Python
python.org โ€บ downloads
Download Python | Python.org
October 9, 2025 - For more information visit the Python Developer's Guide.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ what does a python interpreter do?
r/learnpython on Reddit: What does a Python interpreter do?
November 28, 2020 -

Iโ€™ve been trying to understand exactly what an interpreter does, and how itโ€™s different from a compiler.

From my understanding:

Python converts the code to bytecode, and then the Python Virtual Machine/interpreter executes the script line for line checking for errors.

Is that accurate? What exactly is the role of an interpreter? Also, does the PVM not need the code to be in machine language to understand it?

Top answer
1 of 13
103
When it comes to programming, there are kind of three debatable levels of code: source code, byte code, and machine code. Humans usually write source code, the source code gets compiled into byte code, and then byte code gets compiled into machine code. In languages like C and C++, the byte code portion is kind of hidden away as compilers like GCC will output machine code from source code. Newer compilers like LLVM introduce the concept of byte code but that's out of scope for your question. Languages like Java (and things that use LLVM) compile your source code into byte code which is then executed at runtime in a virtual machine which converts it to machine code. Languages like Python skip all compilation and the interpreter translates source code into machine code at runtime. This is only half true as *.pyc files are actually compiled byte code but these aren't usually exposed directly to a user. EDIT: My second note about LLVM was poorly worded and thus misleading.
2 of 13
23
Python converts the code to bytecode, and then the Python Virtual Machine/interpreter executes the script line for line checking for errors. There's a compiler stage that converts the source code to bytecode. Later, the Python VM then executes that bytecode. It does not do it line by line, because the bytecode has no lines. Rather, it's a sequence of relatively simple operations called opcodes. You can use the dis module to inspect them. Errors caught by the VM during execution are called runtime errors and those caught by the compiler stage are called compile-time errors. Since the Python compiler does comparatively little, usually the only kind of compile-time errors you're likely to see are syntax errors, like unmatched parentheses, missing colons and so on. This is why, for example with this script: print('hello') if False pass print(' world') will NOT print 'hello' before crashing due to a missing colon. It'll crash before even executing. The code is never translated into true machine language in the conventional sense, although of course the VM must contain the machine code necessary to carry out all the opcodes.
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ pycharm โ€บ configuring-python-interpreter.html
Configure a Python interpreter | PyCharm Documentation
1 month ago - To work with your Python code in PyCharm, you need to configure at least one Python interpreter. You can use a system interpreter that is available with your Python installation. You can also create a Virtualenv, pipenv, Poetry, uv, hatch or conda virtual environment.
๐ŸŒ
OnlineGDB
onlinegdb.com โ€บ online_python_interpreter
Online Python Interpreter - online editor
''' Online Python Interpreter. Code, Compile, Run and Debug python program online. Write your code in this editor and press "Run" button to execute it.
Find elsewhere
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ visualstudio โ€บ python โ€บ installing-python-interpreters
Select and Install Python Interpreters - Visual Studio (Windows) | Microsoft Learn
There are several options for installing Python interpreters to work with Visual Studio. You can install an interpreter when you install the Python workload, or you can install an interpreter after a workload is present.
๐ŸŒ
Online Python
online-python.com
Online Python - IDE, Editor, Compiler, Interpreter
Build, run, and share Python code online for free with the help of online-integrated python's development environment (IDE). It is one of the most efficient, dependable, and potent online compilers for the Python programming language. It is not necessary for you to bother about establishing a Python environment in your local.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ what-is-python-interpreter
What is Python Interpreter - GeeksforGeeks
September 18, 2025 - A Python Interpreter is the program that reads and executes Python code.
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ python โ€บ python-tutorial
Getting Started with Python in VS Code
November 3, 2021 - Open the Command Palette (โ‡งโŒ˜P (Windows, Linux Ctrl+Shift+P)), start typing the Python: Create Environment command to search, and then select the command. The command presents a list of environment types, Venv or Conda. For this example, select Venv. The command then presents a list of interpreters that can be used for your project.
Top answer
1 of 16
397

First off, interpreted/compiled is not a property of the language but a property of the implementation. For most languages, most if not all implementations fall in one category, so one might save a few words saying the language is interpreted/compiled too, but it's still an important distinction, both because it aids understanding and because there are quite a few languages with usable implementations of both kinds (mostly in the realm of functional languages, see Haskell and ML). In addition, there are C interpreters and projects that attempt to compile a subset of Python to C or C++ code (and subsequently to machine code).

Second, compilation is not restricted to ahead-of-time compilation to native machine code. A compiler is, more generally, a program that converts a program in one programming language into a program in another programming language (arguably, you can even have a compiler with the same input and output language if significant transformations are applied). And JIT compilers compile to native machine code at runtime, which can give speed very close to or even better than ahead of time compilation (depending on the benchmark and the quality of the implementations compared).

But to stop nitpicking and answer the question you meant to ask: Practically (read: using a somewhat popular and mature implementation), Python is compiled. Not compiled to machine code ahead of time (i.e. "compiled" by the restricted and wrong, but alas common definition), "only" compiled to bytecode, but it's still compilation with at least some of the benefits. For example, the statement a = b.c() is compiled to a byte stream which, when "disassembled", looks somewhat like load 0 (b); load_str 'c'; get_attr; call_function 0; store 1 (a). This is a simplification, it's actually less readable and a bit more low-level - you can experiment with the standard library dis module and see what the real deal looks like. Interpreting this is faster than interpreting from a higher-level representation.

That bytecode is either interpreted (note that there's a difference, both in theory and in practical performance, between interpreting directly and first compiling to some intermediate representation and interpret that), as with the reference implementation (CPython), or both interpreted and compiled to optimized machine code at runtime, as with PyPy.

2 of 16
72

The CPU can only understand machine code indeed. For interpreted programs, the ultimate goal of an interpreter is to "interpret" the program code into machine code. However, usually a modern interpreted language does not interpret human code directly because it is too inefficient.

The Python interpreter first reads the human code and optimizes it to some intermediate code before interpreting it into machine code. That's why you always need another program to run a Python script, unlike in C++ where you can run the compiled executable of your code directly. For example, c:\Python27\python.exe or /usr/bin/python.

๐ŸŒ
Stanford CS
cs.stanford.edu โ€บ people โ€บ nick โ€บ py โ€บ python-interpreter.html
Python Interpreter
You write your Python code in a text file with a name like hello.py. How does that code Run? There is program installed on your computer named "python3" or "python", and its job is looking at and running your Python code. This type of program is called an "interpreter".
๐ŸŒ
Replit
replit.com โ€บ languages โ€บ online-python-compiler
Python Online Compiler & Interpreter - Replit
Write and run Python code using our Python online compiler & interpreter. You can build, share, and host applications right from your browser!
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_compiler.asp
Python Online Compiler (Editor / Interpreter)
Python Variables Variable Names Assign Multiple Values Output Variables Global Variables Variable Exercises Python Data Types Python Numbers Python Casting Python Strings
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ compilers โ€บ online-python-compiler.htm
Online Python Interpreter (Compiler) & IDE - Write, Run & Debug Python Code
Free online Python Interpreter (Compiler) and IDE. Write, compile, run and debug Python code online. No installation required. Supports debugging, code sharing, and multiple examples.
๐ŸŒ
Architecture of Open Source Applications
aosabook.org โ€บ en โ€บ 500L โ€บ a-python-interpreter-written-in-python.html
500 Lines or LessA Python Interpreter Written in Python
Byterun is a Python interpreter implemented in Python. Through my work on Byterun, I was surprised and delighted to discover that the fundamental structure of the Python interpreter fits easily into the 500-line size restriction. This chapter will walk through the structure of the interpreter ...
๐ŸŒ
Python
python.org
Welcome to Python.org
Calculations are simple with Python, and expression syntax is straightforward: the operators +, -, * and / work as expected; parentheses () can be used for grouping.
๐ŸŒ
Programiz
programiz.pro โ€บ ide โ€บ python
Python Playground - Online Python Programming IDE
Python Playground: An online IDE to practice Python programming. Write, edit & run code online. Suitable for all skill levels. Try now.