Share your love
How To Install NumPy on Ubuntu 22.04
In this guide, we want to teach you How To Install NumPy (Numerical Python) on Ubuntu 22.04.
NumPy is a module for Python that allows you to work with multidimensional arrays and matrices. It’s perfect for scientific or mathematical calculations because it’s fast and efficient. In addition, NumPy includes support for signal processing and linear algebra operations. So if you need to do any mathematical operations on your data, NumPy is probably the library for you.
Steps To Install NumPy on Ubutnu 22.04
To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with Ubuntu 22.04.
In this guide, you will learn to install NumPy in two ways:
- Install NumPy from the Ubuntu repository
- Install NumPy with pip/pip3
Let’s see how to do that.
Install Numerical Python from 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 22.04, follow the steps below:
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.21.5
Also, you can install it by using pip or pip3.
Install Numerical Python with pip/pip 3
First of all, you need to install PIP with the following command:
PYTHON 2:
sudo apt install python-pip
PYTHON 3:
sudo 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 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
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 22.04 with the following command:
python3 -c "import numpy; print(numpy.__version__)"
Your output should similar to this:
Output
1.21.5
Upgrade NumPy on Ubuntu 22.04
At this point, you need to upgrade NumPy on Ubuntu 22.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.21.5
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.23.5
Now you have successfully installed NumPy on your server.
Conclusion
At this point, you have learned to Install NumPy (Numerical Python) on Ubuntu 22.04.
Hope you enjoy it.
You may be like these articles:
How To Install Froxlor on Ubuntu 22.04