Learn 2 Best Ways To Install NumPy on Debian Linux

This guide intends to show you how to Install NumPy on Debian Linux. NumPy which stands for Numerical Python, is a fundamental package for scientific computing in Python. It provides support for large, multi-dimensional arrays and matrices, along with a collection of mathematical functions to operate on these arrays efficiently.

You can follow the steps below to Install the Python NumPy Module on Debian Linux such as Debian 12.

Step-by-Step Guide To Install NumPy on Debian Linux

Before you start your NumPy setup, you must log in to your server as a non-root user with sudo privileges. In this guide, we use Debian 12 to show you the guide steps. For this purpose, you can check the Debian 12 Initial Setup Guide.

Then, you can use one of the following methods to install NumPy:

  • Install NumPy from the Debian APT repository
  • Install NumPy with pip/pip3

Method 1 – Install NumPy from the Debian APT repository

NumPy is available in the default Debian repository. First, run the system update with the command below:

sudo apt update

Then, you can simply use the following command to install NumPy:

sudo apt install python3-numpy -y

When your installation is completed, you can verify it by checking the NumPy version:

python3 -c "import numpy; print(numpy.__version__)"
Output
1.24.2

Method 2 – Install NumPy with Python Pip

In this method, you can use Python pip to get the NumPy module in the latest version. To do this, you must install Pip3 on your Debian Linux:

sudo apt install python3-pip -y

Verify your Pip installation by checking its version:

pip3 --version
Output
pip 23.0.1 from /usr/lib/python3/dist-packages/pip (python 3.11)

Now you can use Pip3 to install NumPy on Debian Linux:

pip3 install numpy --break-system-packages

Note: The –break-system-packages flag in pip allows to override the externally-managed-environment error and install Python packages system-wide.

Once your installation is completed, you will get the following output:

Install NumPy on Debian Linux

Also, you can check it by its version:

python3 -c "import numpy; print(numpy.__version__)"
Output
1.26.4

To verify whether NumPy is now part of your Python packages on Debian, you can run:

pip3 show numpy
verify whether NumPy is now part of your Python packages

Import NumPy Package and Set an Alias For it

At this point, you can import the NumPy package and add an alias for it on Debian. To do this, access your Python shell and run the command below:

# python3
>>> import numpy as np

Here we use np for NumPy.

Import NumPy Package and Set an Alias For it

To exit from the Python shell, you can press CTRL+D.

For more information, you can visit the official Docs page.

Conclusion

NumPy provides a solid foundation for numerical computing in Python, offering essential data structures, mathematical functions, and performance optimizations that enable efficient and scalable scientific computing workflows. At this point, you have learned to Install the NumPy on Debian Linux. Hope you enjoy it.

Also, you may like to read the following articles:

Jenkins Server Installation Tutorial on Debian 12

Install build-essential Package in Debian Linux

Install PowerShell on Debian 12 Terminal

Set up Clang LLVM on Debian 12

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!