How to Install Pandas on Ubuntu 24.04
Pandas is a Python data analysis library that organizes messy data into rows and columns. Ubuntu 24.04 ships with Python 3.12 by default, so you can install and set up Pandas in a couple of minutes.
This guide covers three ways to install it from the terminal: APT, pip, and a Python virtual environment. They differ in how current the Pandas version is and in how much they isolate Pandas from the rest of your system. Pick the one that fits your project, then check the install with the verification step in that section.
Install Pandas on Ubuntu 24.04 using `sudo apt update && sudo apt install python3-pandas` for the APT method, or `sudo apt install python3-pip && pip3 install pandas` for the pip method. Verify the installation by running `python3 -c “import pandas as pd; print(pd.__version__)”`.
Install Pandas APT
APT is Ubuntu’s native package manager. It is the fastest way to get Pandas, because it needs no extra tools and installs the library as a normal system package. The catch is that Ubuntu’s packaged version of Pandas can lag behind the latest release. Use this method when you want a simple, stable install and do not need the newest features.
Open a terminal first. Press Ctrl+Alt+T, or search for Terminal in the Activities overview. You need an account with sudo rights.
- Refresh the local package index so APT sees the current state of the repositories. Run `sudo apt update`.
- Enter your password when prompted. Nothing appears on screen as you type, which is normal. Press Enter.
- Wait for the command to finish. You should see a list of repositories being checked, followed by a summary line about how many packages can be upgraded.
sudo apt update sudo apt install python3-pandas
- Install the library and its required dependencies with `sudo apt install python3-pandas`.
- If APT lists the extra packages and asks for confirmation, type Y and press Enter. The terminal prints progress while it downloads and unpacks the packages.
- Confirm the installation by running the command shown below.
python3 -c "import pandas as pd; print(pd.__version__)"
The command prints the version number of the Pandas build that is now active. If you get a “No module named pandas” error instead, the install did not finish. Run the install step again and read the output for errors.
To undo this install later, remove the python3-pandas package with APT.
Install pandas using pip
pip is Python’s package installer. It pulls packages directly from the Python Package Index (PyPI) instead of the older packages in the Ubuntu repositories, so you get the most recent Pandas release. Choose this option if your project needs features the APT version does not have.
One thing to know about Ubuntu 24.04: the system Python is marked as “externally managed”. If you try to install packages with pip straight into it, pip may stop with an externally-managed-environment error. That is a safety feature, not a broken system. If you hit it, use the virtual environment method in the next section.
- Install pip on Ubuntu with the command in the block below. Ubuntu 24.04 does not always include pip by default.
sudo apt update sudo apt install python3-pip
- After pip is installed, import the pandas module with the command below.
- If the command returns to the prompt with no output, the import worked. A “ModuleNotFoundError” means Pandas is not installed for that Python yet.
python3 import pandas as pd
- Verify the pip installation by running the command below.
print(pd.__version__)
The terminal prints the Pandas version number when everything worked. Compare it with the number from the APT method and you will usually see that the pip version is newer.
Install pandas using a Python virtual environment
A Python virtual environment keeps your project’s packages separate from the main system Python. This prevents version clashes between projects on Ubuntu 24.04 and protects the system Python, which Ubuntu’s own tools depend on. It is also the approach Ubuntu 24.04 expects when you want a current Pandas from PyPI. Set one up whenever you work on several projects with different dependency needs.
The steps below all run in the same terminal window. Do not close it until you reach the deactivate step.
- Make sure Python pip is installed, then install the virtual environment package with the commands below. On Ubuntu, the venv module is packaged separately, so creating an environment fails without it.
sudo apt install python3-pip sudo apt install virtualenv
- Create a new virtual environment named project_env with the command below.
- Check your current folder. You should see a new project_env directory there, holding its own copy of the Python setup.
virtualenv project_env
- Activate the environment with the command below.
- Look at your prompt. It should now start with (project_env), which tells you the environment is active. Anything you install from here on goes into this environment only.
source project_env/bin/activate
- Install pandas with the command below. Because the environment is active, you do not need sudo.
- Wait for pip to finish. It downloads Pandas and its dependencies, then ends with a “Successfully installed” line.
pip3 install pandas
- Import the pandas module with the command below. No output and a return to the prompt means the import succeeded.
python3 import pandas as pd
- Check where pandas is installed with the command below.
- Read the location in the output. It should point inside the project_env folder, not to a system path. That confirms Pandas lives in the isolated environment.
print(pd.__version__)
- When you are finished, deactivate the virtual environment with the command below.
- Check that the (project_env) prefix has disappeared from your prompt. To work on the project again, activate the environment once more.
To remove the environment completely, delete the project_env folder. Nothing outside it is affected.
deactivate
Ubuntu 24.04 gives you several ways to set up Pandas, depending on what your project needs. APT is the quickest, pip gives you the newest release, and a virtual environment keeps each project separate.
If this didn’t work:
Verify that your package lists are up to date and that you have sufficient permissions to run package management commands on the system. If a command is not found or the wrong Python answers, you may have more than one Python installation. In that case, use the python3 and pip3 binaries explicitly so the commands run against the right one. If pip stops with an externally-managed-environment error, install inside a virtual environment instead of the system Python. Also check that you are in the terminal where the environment was activated, since a new window starts without it.
- APT Package ManagerQuick and straightforward, and it needs no extra tools, though it may not provide the latest version.
- Pip Package ManagerOffers flexibility in managing packages and ensures you have access to the latest updates. On Ubuntu 24.04, use it inside a virtual environment to avoid the externally-managed-environment error.
- Python Virtual EnvironmentIdeal for project-specific installations, preventing conflicts between package versions and keeping the system Python untouched.
- VerificationAlways verify the installation by checking the Pandas version to ensure it is installed and functioning.
Pandas remains essential for data analysis, and a clean installation saves you trouble later on Ubuntu 24.04. Using `pip`, ideally inside a virtual environment, gives you access to the newest features for demanding data workflows.
Have a question about this guide?
Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.
Did this guide fix your problem?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!