In 2021, Python ranked number one in the TIOBE index, surpassing Java and C#. The language is used to create applications, games, and neural networks, analyze data, and automate processes. Here’s how to install Python on Windows, Linux, and macOS.
Table of Contents
What do you need to install?
In short, source code can be processed by different programs: compilers and interpreters. They do the same job – they convert a high-level programming language into machine code. There are many compilers and interpreters for Python, but CPython is considered the benchmark. This is the original version of the language that users download from the official site. It works best with Python packages and modules. Let’s choose the standard CPython interpreter and see how to install it. Installing CPython All builds of Python for different operating systems are available on the language website. Right now, the most current version, released in December 2021, is Python 3.10.1.
How to install Python on Windows
On the official site, choose Python for Windows, download and run the file. If you already had an earlier version – Python 2 – installed on your computer, uninstall it and download the latest one – Python 3. It is installed by default:
- IDLE (integrated development environment for Python programs)
- Documentation
- The pip package manager (you need it to download and install other Python packages)
- The standard test suite
- Python Launcher
Then select the installation path and specify Install for all users. The easiest way to check that everything works is via the command line.
- Run cmd.exe via task manager or search
- Type “python”
- The command line will display the version of python installed on your system
How to install Python on Linux
Python is included in most Linux builds. To check this, open a terminal window and run the commands:
- python -version
- python2 -version
- python3 -version
If for some reason you have an older version on your system, you can compile the latest version of CPython yourself.
How to Install Python on macOS
Python is also included with macOS, you can run it through the terminal (you can find the terminal in the search box). If you want to install the most recent version, it’s available under Python Releases for macOS.
How to start coding in Python
One of the most convenient ways is to download a code editor. There are editors that support Python Sublimetext plugins, or specifically designed for the language. For example, PyCharm or Thonny. And to write hello world in python all you need is one line: print (“Hello world!”).
Alternatives to CPython
Python has many implementations. For example, Jython is an implementation of Python in Java. Like CPython, the source code is converted to bytecode – a set of instructions for the interpreter. Jython runs on the JVM virtual machine. This implementation helps make working with Java programs more convenient. In addition, Python users have access to the large ecosystem of libraries and frameworks available in Java. There is also IronPython, an implementation for Microsoft .NET platforms written entirely in C#. It runs on a .NET virtual machine. Users can use it to access C# functions and classes, libraries, and .NET frameworks directly from IronPython. There’s also Ruru – it’s most compatible with CPython, which allows you to run web frameworks: for example, Django or Flask. PyPy uses JIT compilation (Just-in-time), which helps compile source code right at runtime. This makes RuPy faster than CPython.