How to Install NumPy on Ubuntu 24.04
NumPy is a Python library that handles large arrays of numbers and fast math calculations on Ubuntu 24.04. Python programs run complex number crunching much faster with this package installed because the core parts use C and Fortran code behind the scenes.
Data analysis and scientific projects rely on this speed boost to process information quickly without slowing down your system.
You can install NumPy on Ubuntu 24.04 using the APT package manager. Open your terminal and run sudo apt install python3-numpy. This command installs NumPy and any necessary dependencies from the Ubuntu repositories.
Install Python and Pip
Python and Pip are required prerequisites for installing NumPy on Ubuntu 24.04, and terminal commands fetch both dependencies.
sudo apt update && sudo apt upgrade
sudo apt install python3 python3-pip
NumPy Using APT
Retrieving NumPy from official Ubuntu software sources via APT offers the most direct deployment path.
Execute this command to install NumPy:
sudo apt install python3-numpy
The package manager resolves all required dependencies automatically during this process.
Install NumPy Using Python Virtual Environment
You can install NumPy on Ubuntu 24.04 inside a Python virtual environment to keep your project packages organised and prevent version conflicts with other software. A virtual environment creates an isolated workspace for your project. First, install the virtual environment tool by opening your terminal and running sudo apt install python3.12-venv.
Run this command to install the required Python environment packages:
sudo apt install python3.12-venv
Create a dedicated virtual environment named myenv for your project next:
python3 -m venv myenv
Activation makes the isolated workspace active in the terminal session.
source myenv/bin/activate
Specific package versions install successfully inside active environments.
pip install numpy==VERSION
Implementation follows this pattern:
pip install numpy==1.26.3
Test the module import afterward to confirm proper installation.
python3
import numpy as np
Output the installed version string with this execution:
print(np.__version__)
Deactivating the virtual environment returns the terminal to the global system state.
deactivate
Configuration finishes here.
Summary:
Multiple deployment methods exist for adding NumPy to Ubuntu 24.04 systems. Core takeaways include:
- Versatile Library: NumPy is essential for numerical and scientific computing, offering various mathematical functions and support for multi-dimensional arrays.
- Installation Methods: You can install NumPy using the APT method for ease or create a virtual environment for better project dependency management.
- Python Requirement: Ensure that you have Python and Pip installed before proceeding with the installation of NumPy.
- Version Control: Installing NumPy in a virtual environment allows you to manage different library versions easily, which is particularly useful for multiple projects.
- Verifying Installation: Always verify the installation by checking the NumPy version to confirm that the library is set up correctly.
Numerical computing tasks on Ubuntu 24.04 execute reliably once these configuration steps complete.
Was this guide helpful?
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!