How to Install Python on Ubuntu and Windows: A Step-by-Step Guide

3 min read

01 Jan, 2025

Python

Python is one of the most popular programming languages in the world, known for its simplicity and versatility. Whether you are a beginner or an experienced developer, we will walk you through the process of installing Python on both Ubuntu and Windows.

thumbnail

Installing Python on Ubuntu

Ubuntu comes with Python pre-installed. However, it might not be the latest version. Here’s how you can check your Python version and install or update Python on your Ubuntu system.

Step 1: Check if Python is Already Installed

Open a terminal and type:

python3 --version

python3 --version If Python is installed, you will see the version number. For example:

Python 3.9.7

If Python is not installed or you need to update it, follow the next steps.

Step 2: Update the Package List

Before installing Python, update your system’s package list:

sudo apt update

Step 3: Install Python

To install the latest version of Python, run:

sudo apt install python3

Step 4: Install pip (Python Package Manager)

pip is a tool for installing Python packages. You can install pip with:

sudo apt install python3-pip

Step 5: Verify the Installation

Check the Python and pip installations by running:

python3 --version pip3 --version

Now Python and pip are installed and ready to use on your Ubuntu system.

Installing Python on Windows

Installing Python on Windows is straightforward. Follow these steps to get started:

Step 1: Download the Python Installer

  • Visit the official Python website: https://www.python.org
  • Navigate to the “Downloads” section and select the latest version for Windows.

Step 2: Run the Installer

  • Double-click the downloaded file to run the installer.
  • On the installation screen, check the box that says "Add Python to PATH". This is important for running Python from the command line.
  • Click “Install Now” to begin the installation.

Step 3: Verify the Installation

Once the installation is complete, verify it by opening Command Prompt and typing:

python --version

You should see the installed version of Python.

Step 4: Install pip (If Not Included)

Most Python installers for Windows include pip. To check if pip is installed, type:

pip --version

If pip is not installed, you can install it by downloading the get-pip.py script from the official Python website and running:

python get-pip.py

Step 5: Set Up Environment Variables (Optional)

If you didn’t check “Add Python to PATH” during installation, you can set up the PATH manually:

  • Search for "Environment Variables" in the Windows search bar.
  • Click “Environment Variables” under the System Properties window.
  • Find “Path” under System Variables, select it, and click “Edit”.
  • Add the path to the Python installation directory (e.g., C:\Python39) and the Scripts folder (e.g., C:\Python39\Scripts).
  • Click “OK” to save.

Step 6: Test the Installation

Test Python and pip by running:

python --version
pip --version

Conclusion

You have now installed Python on both Ubuntu and Windows! Whether you're using Python for web development, data analysis, or automation, having the latest version ensures compatibility with the newest libraries and features. Happy coding!