Python Tutorial



Python Tutorial

Install Python on Linux


Python has become incredibly popular among developers since it is a flexible and potent programming language. You will be guided through the installation of Python on Linux in this article, giving you the necessary resources to start your programming career. This instruction will guarantee a smooth installation process, regardless of your level of programming experience. Let's get started by investigating the procedures, choices, and factors involved with installing Python on Linux.

Installing Python is the first essential step in embracing Python programming's capability on a Linux machine. This guide will help you install Python on Linux without any problems, allowing you to take full advantage of this flexible language in the Linux environment. This installation process will create the framework for your Python explorations, whether you're a newbie eager to learn how to code or an experienced developer switching to Linux.


Installing Python on a Linux system is a fundamental step for any developer or system administrator, as Python is a widely used programming language for a variety of applications, including web development, data analysis, automation, and more. This comprehensive guide provides an overview of the steps to install Python on a Linux distribution, highlighting the importance and various methods available for the installation process.

1. Why Install Python on Linux:

Python is often pre-installed on many Linux distributions, but you may need to install it manually or update it to a specific version for your project. Python is essential for running Python scripts, developing applications, and using various Python libraries and frameworks.

2. Checking Existing Python Installations:

Before installing Python, it's a good practice to check if Python is already installed on your Linux distribution. Open a terminal and type python --version or python3 --version to check the installed version.

3. Verifying the Installation:
After installation, verify that Python is installed correctly by opening a terminal and running python --version or python3 --version.

4. Installing Pip:

Pip is a package manager for Python that allows you to install Python packages and libraries easily. It is usually bundled with Python, but you may need to install it separately on some distributions.

5. Setting up Virtual Environments (Optional):

To isolate Python environments for different projects and avoid version conflicts, consider setting up virtual environments using tools like venv or virtualenv.

6. Updating Python:

Periodically, you may want to update Python to the latest version for security updates and new features. You can use your package manager or the method you initially used to install Python to update it.

7. Troubleshooting and Tips:

If you encounter issues during installation or need further assistance, consult the documentation for your specific Linux distribution and the Python community. Common issues include package conflicts and missing dependencies.

The Importance of Python Installation

Python serves as a gateway to a wide array of programming possibilities, from web development to data analysis and artificial intelligence. By having Python installed on your Linux system, you open the door to a world of coding creativity, problem-solving, and innovation. Whether you're a novice programmer or an experienced developer, the ability to install Python efficiently is a fundamental skill that empowers you to harness the language's capabilities.

Prerequisite to Install Python on Linux

Before installing Python on Linux, there are a few prerequisites you should ensure are in place to facilitate a smooth installation process. Let's explore these prerequisites with examples:

1. Access to the Terminal:
You need access to the terminal to execute commands. Most Linux distributions provide a terminal emulator by default.
Example: Open the terminal by pressing 'Ctrl + Alt + T'.

2. Package Manager:
Make sure your Linux distribution has a package manager installed.
Example: On Debian-based systems like Ubuntu, you can use 'apt'. On Red Hat-based systems, use 'yum' or 'dnf'.

3. Superuser Privileges:
You'll need administrative privileges (sudo) to install software system-wide.
Example: Run the following command to install using 'sudo':

sudo apt-get install python3

4. Internet Connection:
An active internet connection is required to download Python and its dependencies.
Example: Ensure your system is connected to the internet before proceeding.

5. Update Package Lists:
Update your package lists to get the latest available packages from repositories.
Example: Run the following command to update package lists:

sudo apt-get update

By ensuring these prerequisites, you'll be well-prepared to install Python on your Linux system. Always refer to your specific Linux distribution documentation for any distribution-specific variations or requirements.

How to Check the Python Version on Linux?

Checking the Python version on Linux is a simple process that involves using the terminal. Here's how you can do it, along with examples:

1. Open Terminal:
Open the terminal on your Linux system. You can typically do this by pressing 'Ctrl + Alt + T'.

2. Check Python Version:
Use the following command to check the installed Python version:



In this example, the Python version is displayed as '3.8.10'.

3. Check Python 3 Version:
If you have both Python 2 and Python 3 installed, you might need to use 'python3' instead of 'python' to check the Python 3 version:



Again, the Python 3 version is displayed as '3.8.10'.

By using either 'python --version' or 'python3 --version' commands, you can quickly verify the installed Python version on your Linux system. This information is useful when ensuring compatibility for your scripts and projects.

Two Ways to Install Python on Linux

  • Install Python on Linux from Package Manager

Kindly note that this subject has been addressed comprehensively in previous sections of this document (‘Prerequisite to Install Python on Linux’).

  • Build Python from Source Code

Step 1: Get the Source Code
Download the Python source code from the official website or use tools like wget. Extract the downloaded archive.



Step 2: Configure
Navigate to the extracted directory and configure the build by running the configure script.


Step 3: Build
Compile and build Python using the 'make' command.


Step 4: Install
Install the compiled Python using 'make install'.


Step 5: Verify Installation
Check the installed Python version to ensure the successful installation.


By following these methods, you can choose the most suitable approach to install Python on your Linux system. The package manager provides ease while building from source code and offers customization. Select the method that fits your requirements and embark on your Python programming journey.


In conclusion, the process of setting up Python on your Linux machine is a fundamental and pivotal step in your programming journey. It serves as the foundational framework upon which your future programming endeavors will be built. Regardless of your prior experience or expertise level, the comprehensive instructions provided in this guide ensure that you have the necessary knowledge and skills to set up Python smoothly and efficiently on your Linux system.

It's time to start coding and unleash the immense power of Python on your Linux platform, allowing it to serve as a catalyst for your creativity and a gateway to a world of endless possibilities in the realm of software development. Your journey has just begun, and Python is your trusted companion on this exciting and transformative path.


1. Is it necessary to install pip after installing Python?
While Python comes with pip pre-installed in recent versions, installing it separately provides access to a wide range of third-party libraries.

2. What's the difference between Python 2 and Python 3?
Python 3 is the latest version with improvements, enhancements, and backwards-incompatible changes. Python 2 has reached its end of life and is no longer maintained.

3. Can I uninstall the system-installed Python?
Be cautious about uninstalling system-installed Python, as it may disrupt system functions. It's safer to use virtual environments for specific projects.

4. Which method is better: package manager or building from source?
It depends on your needs. Package managers are easier and ensure compatibility while building from source offers customization options.

5. How do I install Python packages after installing Python?
Use ‘pip’ (Python's package installer) to install packages. For example, ‘pip installs numpy’.

6. Is it necessary to update package lists before installing Python?
Yes, updating package lists with apt-get update or similar commands ensures you're working with the latest information about available packages.

7. How can I install Python 3 using a virtual environment on Linux?
You can create a virtual environment using the 'venv' module (if it's not already installed, use 'sudo apt-get install python3-venv' or the equivalent command for your distribution), and then activate the environment to install Python packages.

Leave a Reply

Your email address will not be published. Required fields are marked *