Share your love
How To Install NumPy on Ubuntu 20.04

In this article, we want to teach you How To Install NumPy on Ubuntu 20.04.
NumPy which stands for Numerical Python is a free and open-source Python library used for working with arrays. It also has functions for working in the domain of linear algebra, Fourier transform, and matrices.
How To Install NumPy on Ubuntu 20.04
Before you start to install NumPy on Ubuntu 20.04, you need to log in to your server as a non-root user with sudo privileges. To do this you can check our article about the Initial server setup with Ubuntu 20.04.
When you are done with this requirement, you can start to install NumPy on your server in different ways.
Install NumPy from the Ubuntu repository
Numpy is available in the Ubuntu default repository by default. You can choose to use Python 2 or Python 3. Also, you may want to choose both. To install NumPy on ubuntu 20.04 run the following command:
PYTHON 2: sudo apt install python-numpy
PYTHON 3: sudo apt install python3-numpy
Now you need to verify the installation by checking the NumPy version with the following command:
python3 -c "import numpy; print(numpy.__version__)"
In your output you will see:
Output
1.17.4
Also, you can install it by using pip or pip3.
Install NumPy with pip/pip3
First of all, you need to install PIP with the following command:
PYTHON 2: sudo apt install python-pip
PYTHON 3: udo apt install python3-pip
Then, you need to verify the installation by checking the pip or pip 3 versions with the following command:
pip3 --version
In your output you will see something similar to this:
Output
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
Here you can easily use pip or pip 3 to install NumPy with the following command:
PYTHON 2: pip install numpy
PYTHON 3: pip3 install numpy
Now you need to confirm the installation by checking the NumPy version on Ubuntu 20.04 with the following command:
python3 -c "import numpy; print(numpy.__version__)"
Your output should similar to this:
Output
1.17.4
At this point, you need to upgrade NumPy on Ubuntu 20.04 to the latest version. To do this run the following command:
PYTHON 2: pip install --upgrade numpy
PYTHON 3: pip3 install --upgrade numpy
In your output you will see:
Output
Installing collected packages: numpy
Attempting uninstall: numpy
Found existing installation: numpy 1.17.4
Not uninstalling numpy at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'numpy'. No files were found to uninstall.
Successfully installed numpy-1.21.2
Conclusion
At this point, you learn to install NumPy from the ubuntu repository and you can also use pip or pip 3 to install it.
Hope you enjoy this article about How To Install NumPy on Ubuntu 20.04.