Lesson 5 of 70 – Python Installation
7%

Python Installation

Before writing and executing Python programs, you need to install Python on your computer. Python is available for Windows, macOS, and Linux.

Note: For new projects and learning, use a currently supported version of Python 3. Python 2 is no longer supported.
System Requirements

Python can run on most modern computers. Before installation, make sure your operating system is supported and that you have permission to install software on your computer.

  • Windows computer
  • macOS computer
  • Linux computer
  • Internet connection for downloading Python
  • Administrator permission may be required on some systems
Download Python

Python can be downloaded from the official Python website.

Official Website:

https://www.python.org/

Visit the Python website and open the download section. Select the appropriate installer for your operating system.

Important: Always download Python from the official Python website or a trusted software repository.
Installing Python on Windows

Follow these steps to install Python on Windows.

  1. Open the official Python website.
  2. Go to the Downloads section.
  3. Download the Windows installer for Python 3.
  4. Open the downloaded installer.
  5. Select the option to add Python to the system PATH.
  6. Click the installation option.
  7. Wait for the installation to complete.
  8. Close the installer after successful installation.
Add Python to PATH

When installing Python on Windows, you may see an option to add Python to the system PATH.

Enabling this option makes it easier to run Python from the Command Prompt or PowerShell.

Recommended: Enable the option that adds Python to PATH during installation if you want to run Python commands directly from the terminal.

After installation, you can check whether Python is available from the terminal.

Check Python Installation on Windows

Open Command Prompt or PowerShell and type the following command:

python --version

You can also try:

py --version

If Python is installed correctly, the command will display the installed Python 3 version.

Example Output:
Python 3.x.x

The exact version number may be different depending on the version installed on your computer.

Installing Python on macOS

Python 3 can be installed on macOS using the official Python installer or another trusted package-management method.

  1. Visit the official Python website.
  2. Open the Downloads section.
  3. Select the macOS installer for Python 3.
  4. Download the installer.
  5. Open the downloaded package.
  6. Follow the installation instructions.
  7. Complete the installation.

After installation, open Terminal and check the Python version.

python3 --version
Installing Python on Linux

Many Linux distributions provide Python 3 through their package manager. The exact installation command depends on the Linux distribution.

For example, on Debian or Ubuntu-based systems, Python 3 can commonly be installed using the system package manager.

sudo apt update
sudo apt install python3

After installation, check the version:

python3 --version
Note: Package names and commands can vary between Linux distributions. Use the package manager recommended by your distribution.
Python Interactive Shell

After installing Python, you can open the Python interactive interpreter from the terminal.

On many systems, use:

python

or:

python3

You will see a prompt similar to:

>>>

You can now enter Python commands directly.

Example:
>>> 10 + 20
30
Check Python with a Simple Program

You can create a simple Python file to verify that Python is working correctly.

Step 1: Create a file
hello.py
Step 2: Add Python code
print("Hello, Python!")
Step 3: Run the program

Open the terminal in the folder containing the file and run:

python hello.py

On systems where Python 3 is invoked using python3, use:

python3 hello.py
Output:
Hello, Python!
Verify pip Installation

pip is the package installer commonly used to install Python packages from the Python Package Index (PyPI).

You can check whether pip is available using:

pip --version

On some systems, you may use:

pip3 --version

The command displays the installed pip version and related information.

Uninstalling Python

If you need to remove Python, use the normal software management tools provided by your operating system.

  • On Windows, use Apps or Installed Apps in Settings.
  • On macOS, follow the installation method's removal instructions.
  • On Linux, use the distribution's package manager when appropriate.
Important: Do not remove the system Python installation on Linux unless you understand the consequences. Some operating-system components may depend on it.
Common Installation Problems
1. Python command is not recognized

If the terminal cannot find Python, check whether Python was added to PATH or use the appropriate Python command for your operating system.

2. Wrong Python version

Check the installed version using:

python --version
3. pip command is not recognized

Try checking pip with:

python -m pip --version
4. Multiple Python versions

If multiple Python versions are installed, make sure you know which interpreter your project is using.

Recommended Tools for Python Development

After installing Python, you can choose a code editor or integrated development environment (IDE) for writing programs.

  • Visual Studio Code
  • PyCharm
  • IDLE
  • Jupyter Notebook

Beginners can start with IDLE or Visual Studio Code. As you progress, you can explore other development environments.

Python Installation Checklist
  • Download Python 3.
  • Install Python on your operating system.
  • Add Python to PATH on Windows when appropriate.
  • Open the terminal or command prompt.
  • Check the Python version.
  • Check pip.
  • Create a simple Python file.
  • Run the Python program.
Key Points
  • Python 3 is the modern Python series used for current development.
  • Python can be installed on Windows, macOS, and Linux.
  • Python can be downloaded from the official Python website.
  • Windows users can check Python using python --version or py --version.
  • macOS and Linux users may use python3 --version.
  • Python programs normally use the .py extension.
  • pip is commonly used to install Python packages.
  • Python can be used through the terminal or an IDE.
  • A simple print() program can be used to test the installation.

🧠 Quick Quiz

Which command can be used to check the installed Python version on Windows?