Python is one of the most popular, versatile, and widely-used programming languages today, underpinning everything from web development and automation to data science and artificial intelligence. Pip is Python’s official package manager, allowing you to install, update, and manage third-party Python software packages easily.
Ubuntu 24.04 LTS, being a modern and stable Linux distribution, comes equipped with Python pre-installed, but sometimes you may want to install a specific Python version or set up pip to start managing Python libraries effectively.
This guide will take you through the process of installing both Python and pip on Ubuntu 24.04 LTS, step-by-step, including tips on verifying the installation and managing Python environments.
Prerequisites
Before starting the installation:
- You need a running Ubuntu 24.04 LTS system (local machine or VPS).
- Ensure you have a user account with sudo privileges.
- You should have access to a terminal or SSH client.
- A stable internet connection for downloading packages.
How to Install Python and Pip on Ubuntu
Step 1: Check Existing Python Installation
Ubuntu 24.04 LTS usually ships with Python 3.12 pre-installed. To confirm this, open your terminal and run:
python3 --version
You should see output like:
Python 3.12.3
If Python 3 is installed, you can proceed to set up pip. If Python is not installed or you want a different version, follow the next step to install or update Python.cherryservers+2
Step 2: Install or Update Python on Ubuntu 24.04 LTS
Even though Python is generally pre-installed, you might want to ensure you have the latest patched version or install multiple Python versions side by side.
Basic Python 3 Installation
Update your package list:
sudo apt update
Then install Python 3:
sudo apt install python3 -y
Verify the installation:
python3 --version
Installing Specific Python Versions
If you want a specific version like Python 3.10, Ubuntu supports installing it from the deadsnakes PPA:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.10
Switch between them by invoking python3.10 directly or configuring alternatives.vultr
Step 3: Install Pip for Python 3
Pip simplifies installing and managing additional Python packages. To install pip on Ubuntu 24.04:
sudo apt install python3-pip -y
This command installs pip and its dependencies.
Check the pip version installed:
pip3 --version
Example output:
pip 24.0 from /usr/lib/python3/dist-packages/pip (python 3.12)
Step 4: Managing Pip and Python Packages
With pip installed, you can now install any Python package available on the Python Package Index (PyPI). For example:
pip3 install requests
To upgrade pip itself:
pip3 install --upgrade pip
Remember to use pip3 explicitly, as pip may point to Python 2’s package manager if installed.
Step 5: Using Virtual Environments (Optional but Recommended)
To keep project dependencies isolated and avoid conflicts, use Python virtual environments.
Install the virtual environment package:
sudo apt install python3-venv -y
Create a new virtual environment:
python3 -m venv myenv
Activate it:
source myenv/bin/activate
Once activated, pip3 install commands install packages only within this environment, keeping your global Python setup clean.
To exit the environment, use:
deactivate
Step 6: Alternative – Installing Python 2.7 & Pip (Legacy Use)
Ubuntu 24.04 LTS does not include Python 2.7 by default since it’s end-of-life. If required for legacy applications, you must compile it from source:
- Update system and install dependencies
- Download Python 2.7.18 source tarball and compile manually
Because of its complexity and obsolescence, it’s better to migrate to Python 3, but the process is available online if needed.github
Troubleshooting Tips
command not founderrors: Ensure you installed packages withsudo, and that the binaries likepython3andpip3are on your PATH.- Permission issues with pip: Use virtual environments or run pip with
--userfor local installs. - Mismatch of Python and pip versions: Always use
python3andpip3explicitly to avoid version conflicts. - Update package lists: Always run
sudo apt updatebefore installing new software.
Summary
To recap, here’s the concise sequence:
- Check existing Python version:
python3 --version - Update packages:
sudo apt update - Install Python 3 (if needed):
sudo apt install python3 - Install pip for Python 3:
sudo apt install python3-pip - Verify pip:
pip3 --version - (Optional) Use virtual environments for isolated package management.
This approach will get your Ubuntu 24.04 LTS system fully equipped for Python development swiftly and reliably.
Why This Matters
Python and pip form the foundation for an immense ecosystem of tools and frameworks in today’s technology landscape—from web frameworks like Django and Flask, data science libraries like Pandas and NumPy, to machine learning and automation scripts. Ubuntu’s ease of use and large community support make it an ideal platform for Python development, and mastering how to install and configure these tools correctly is key to being productive and avoiding dependency conflicts.
Start your journey with this guide, and soon you’ll be ready to build, automate, analyze, and explore almost any Python application on your Ubuntu 24.04 LTS system.
FAQs on How to Install Python and Pip on Ubuntu 24.04 LTS
Is Python pre-installed on Ubuntu 24.04 LTS?
Yes, Ubuntu 24.04 LTS comes with Python 3.12 pre-installed by default. You can verify the version by running python3 --version in the terminal.
How do I install pip on Ubuntu 24.04?
You can install pip, the Python package manager, by running:
sudo apt install python3-pip
After installation, verify it with pip3 --version.
What is the difference between pip and pip3?
pip often points to the Python 2 package manager on some systems, while pip3 explicitly refers to the Python 3 package manager. Since Ubuntu 24.04 uses Python 3, always use pip3 to avoid confusion
How can I install a specific Python version on Ubuntu 24.04?
Use the deadsnakes PPA repository for installing specific Python versions like 3.10:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.10
You can then switch versions using alternatives commands.
How to manage multiple Python versions on Ubuntu 24.04?
Install multiple Python versions and configure default version with:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.x 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.y 2
sudo update-alternatives --config python3
This lets you choose between installed Python versions.
Should I use virtual environments with Python and pip?
Yes. Virtual environments isolate project dependencies and Python versions, preventing package conflicts. Use:
sudo apt install python3-venv
python3 -m venv myenv
source myenv/bin/activate
Deactivate with deactivate.
Can I install Python 2.7 and pip on Ubuntu 24.04?
Python 2.7 is no longer included by default and has reached end-of-life. If absolutely necessary, you must compile it manually from source. Transitioning to Python 3 is highly recommended.
What if I encounter permission issues using pip?
Avoid installing packages globally without sudo. Use virtual environments or the --user option:
pip3 install --user package_name
This installs packages locally for your user account.
How do I upgrade pip to the latest version?
Run:
pip3 install --upgrade pip
within your environment or globally to get the newest pip features.
How do I verify that Python and pip are correctly installed?
Check Python version:
python3 --version
Check pip version:
pip3 --version
Enter Python shell with python3 and run a test command like print("Hello, Python!").

How to Install Python on Ubuntu 24.04 LTS