Before we can run Python code on our computer, we need to install the Python interpreter on our system.
Fortunately, this is a very simple process and is compatible with the major operating systems.
Install Python
Windows
To install Python on a Windows system, we can download the installer from the official Python website (https://www.python.org/downloads/).
Once the installer is downloaded, simply run the file and follow the installation wizard’s instructions.
Linux
In most Linux distributions, Python is already installed by default. If we need to install a more recent version, we can use the package manager of our distribution.
For example, apt in Ubuntu or yum in CentOS.
sudo apt install python3
macOS
In macOS, Python is already pre-installed on the system. However, we may need to install a more recent version or manage multiple versions of Python. For this, we can use tools like Homebrew or pyenv.
Verify the installation
Once the installation is complete, it is advisable to verify that Python has been installed correctly on your system.
To do this, open a terminal window and type the following command,
python --version
This command should print the version of Python installed on your system. If you see something like:
Python 3.x.x
Where 3.X.X
is the version of Python, congratulations! You have successfully installed Python on your system 🥳.
Development Environments
Now that we have Python installed on our system, we need a development environment where we can write, debug, and execute our code.
There are several popular development environments for Python, each with its own features and advantages.
IDLE
IDLE is the integrated development environment (IDE) that comes included with the standard installation of Python. It provides a code editor, an interactive Python interpreter, and basic debugging tools.
IDLE is very basic, and I only recommend it for the simplest tasks or for a couple of quick tests. It is more common to use a more complete IDE like VS Code 👇.
Visual Studio Code
Visual Studio Code is a lightweight and highly customizable code editor that has a wide range of extensions, making it a powerful development environment for Python. It offers support for debugging, version control, integration with virtual environments, and much more.
We will see how to set up Visual Studio Code to work with Python in the next article.