Python is a powerful programming language that’s easy to learn and widely used in industries ranging from web development to data science. But before starting Python, you first need to install Python on your computer. In this guide, I will show you the process of Python installation on three popular operating systems: Mac, Linux, and Windows.
Table of Contents
Check if Python already Installed
Before installing Python, it’s a good idea to check whether it’s already installed on your system.
On Mac and Linux:
- Open the Terminal. (You can find Terminal in the Applications folder on Mac or by searching for it.)
- Type the following command and press Enter:
python3 --version
Bash- If Python is installed, you’ll see something like this:
Python 3.x.x
BashThe numbers represent the version installed. If Python is not installed, don’t worry I will guide you through the installation steps.
On Windows:
- Open the Command Prompt. (You can search for “cmd” in the Start menu.)
- Type the following command and press Enter:
python --version
Bash- If Python is installed, you will see the version number.
1. Installing Python on Linux
Most Linux distributions come with Python pre-installed. However, if you want to install the latest version, follow these steps:
Step 1: Update Your Package Manager
- Open the Terminal
- Type the following command and press Enter:
sudo apt update
Bash(Use yum
instead of apt
for Red Hat-based distributions.)
Step 2: Install Python
- Run this command to install Python:
sudo apt install python3
Bash- For Red Hat-based distributions, use:
sudo yum install python3
Bash- Verify the installation by typing:
python3 --version
BashSo Python is installed in your Linux system. But be careful, as Linux itself depends on Python; changing the default Python version can cause issues with your operating system’s functionality.
2. Installing Python on Mac
Step 1: Install Homebrew (Optional but Recommended)
Homebrew is a package manager for macOS that makes installing software easier.
- Open Terminal.
- Paste the following command and press Enter:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Bash- Follow the on-screen instructions.
- Once Homebrew is installed, update it by running:
brew update
BashStep 2: Install Python Using Homebrew
- In Terminal, type:
brew install python
Bash- After the installation is complete, verify it by running:
python3 --version
Bash3. Installing Python on Windows
Installing Python on Windows is a bit different but still very simple.
Step 1: Download the Python Installer
- Open your browser and go to the official Python website: https://www.python.org
- Click on Downloads and select Windows.
- Download the latest Python version.
Step 2: Run the Installer
- Open the downloaded file to start the installation.
- On the first screen, check the box that says Add Python to PATH. This step is very important!
- Click Install Now.
Step 3: Verify the Installation
- Open the Command Prompt.
- Type:
python --version
BashPython is now installed on your local computer.
Installing a Code Editor (Optional)
You can write Python code in any text editor, using a dedicated code editor or an IDE (Integrated Development Environment) makes coding much easier. Here are two popular options:
1. Visual Studio Code (VS Code):
- Download from https://code.visualstudio.com.
- Install Python extensions for additional features like syntax highlighting and debugging.
2. PyCharm:
- Download from https://www.jetbrains.com/pycharm/.
- It’s a powerful IDE specifically designed for Python.
Conclusion
Congratulations Guys! Python has been successfully installed on your computer. It doesn’t matter what operating system you are using Mac, Linux, or Windows. Python is a versatile and cross-platform programming language and can be used on any operating system.