Python is a versatile and widely-used programming language, essential for everything from web development to data science and automation. Ubuntu 24.04 typically comes with Python 3 pre-installed, but you’ll often need to install `pip`, Python’s package installer, to manage additional libraries and modules. This Tutorial will guide you through verifying your Python 3 installation and setting up `pip` on your Ubuntu 24.04 system.
First, it’s always a good practice to update your package lists and upgrade any installed packages to their latest versions. Open your terminal and run the following commands:
sudo apt update
sudo apt upgrade -y
Next, let’s verify if Python 3 is already installed on your system. Ubuntu 24.04 usually includes it by default. You can check its version with:
python3 --version
If Python 3 is installed, you will see its version number (e.g., `Python 3.12.2`). If it’s not installed for some reason, or if you need to ensure all necessary components are present, you can install it using `apt`:
sudo apt install python3 -y
After confirming Python 3, the next crucial step is to install `pip`, the package installer for Python. `pip` allows you to install and manage additional Python libraries and frameworks that are not part of the standard Python library. You can install `pip` for Python 3 using the following command:
sudo apt install python3-pip -y
Once `pip` is installed, you can verify its installation and check its version:
pip3 --version
This command should output the `pip` version along with the Python version it’s associated with (e.g., `pip 24.0 from /usr/lib/python3/dist-packages/pip (python 3.12)`). Note that we use `pip3` to explicitly refer to the `pip` version compatible with Python 3, especially if you have multiple Python versions installed.
You can now use `pip3` to install any Python package you need. For example, to install the popular `requests` library, you would run:
pip3 install requests
To upgrade `pip` itself to the latest version, which is often recommended, you can use `pip` to upgrade itself:
pip3 install --upgrade pip
By following these steps, you have successfully installed Python 3 and `pip` on your Ubuntu 24.04 system, equipping you with the fundamental tools to develop and run Python applications and manage their dependencies efficiently. You’re now ready to explore the vast ecosystem of Python libraries!
