Like practically anything these days, you can also run Python in a browser. On our learning platform, learn.python.land, you can enter Python code, run it, and see the results. All without the need to install Python and launch a Python REPL yourself. You can use it while working your way through the Python tutorial for beginners.
Running Python in the browser
In short, If you:
- don’t feel like installing Python (yet),
- would like to get started quickly,
- want to try if Python is for you before installing it
you’re in luck! You can get started right away without the need to install anything.
Using Python in a browser is fine for learning and fiddling around. However, once you start to get serious about Python development, you will find out that, at some point, you’ll want a proper IDE (Integrated Development Environment) and a local installation of Python. I recommend installing Python on your PC if you can; it’ll offer a much better experience and allow you to work offline too. Head over to our Python installation guide to learn how to install Python on your computer.
Prefer an exercise to get you started? Try our free Python playground lesson on the new learning platform. Change a small program, run it in your browser, and check your answer.
The online Python interpreter
The practice lessons on learn.python.land have a code editor with a Run button. Your code runs as a real Python program, and you see its output right away. Submit checks whether your code does what the exercise asks, and Step walks through your program one instruction at a time, so you can see what each line does. The free first lesson, Meet the Python Playground, shows you around.
Would you rather run Python inside a web page you build yourself? Then have a look at PyScript, which runs Python code directly in the browser.
Other ways to run Python in your browser
Our playground is built for learning, with exercises that check your answer. If you just want a place to run some Python, there are a few other free options:
- The Pyodide console is a real Python REPL that runs entirely in your browser. Pyodide is the project that makes this possible, and PyScript is built on top of it.
- JupyterLite gives you JupyterLab in the browser, also powered by Pyodide. It’s a good way to try out Jupyter notebooks without installing anything.
- Google Colab runs notebooks on Google’s servers instead of in your browser. You need a Google account, but you get packages like pandas and NumPy preinstalled, and even access to GPUs.
Code that runs in the browser with Pyodide has some limits. Not every package works, and things like network access and reading files on your computer are restricted. For small experiments, that rarely matters.
Not a REPL
Please note that the playground is not a REPL or interactive terminal. You write a real Python file and run it as a whole. So if you want to see the output, you need to use the print() function to print it. Here are a couple of examples to get you started:
print(1 + 3)
# will print 4
print('Hello world')
# will print Hello world
a = 6 + 9
print(a)
# will print 15Code language: Python (python)
Questions?
If you have any questions or comments, please contact me here.