NumPy is a Python library, which supports large, multi-dimensional arrays and matrices. It also offers a wide set of high-level mathematical functions to operate on these arrays. The objective of this short guide is to install NumPy on Ubuntu 20.04 Focal Fossa Linux.
In this tutorial you will learn:
- How to install Numpy from the Ubuntu repository
- How to install Numpy using pip or pip3 commands
- How to upgrade Numpy to its latest version
Software Requirements and Conventions Used
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Installed or upgraded Ubuntu 20.04 Focal Fossa |
Software | python,python3 |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Install Numpy on Ubuntu 20.04 step by step instructions
Install Numpy from Ubuntu repository
- To install Numpy on Ubuntu 20.04 execute the following command. Make a selection between Python 2 or Python 3 or possibly install both:
PYTHON 2: $ sudo apt install python-numpy PYTHON 3: $ sudo apt install python3-numpy
- Check Numpy version:
$ python -c "import numpy; print(numpy.__version__)" 1.16.5 $ python3 -c "import numpy; print(numpy.__version__)" 1.17.4
Install Numpy using pip / pip3 command
- Given that you have already installed Python installer pip on you Ubuntu 20.04 host, you can now easily install
numpy
by using thepip
orpip3
command:PYTHON 2: $ pip install numpy PYTHON 3: $ pip3 install numpy
- Check Numpy version:
$ python -c "import numpy; print(numpy.__version__)" 1.16.5 $ python3 -c "import numpy; print(numpy.__version__)" 1.17.4
Upgrade numpy to latest version
In case you have installed numpy
from the Ubuntu repository you can upgrade it by simply executing the following Linux command:
PYTHON 2: $ sudo apt install python-numpy PYTHON 3: $ sudo apt install python3-numpy
Execute the bellow commands, in case you need to upgrade numpy to the latest version with the pip
or pip3
:
PYTHON 2: $ pip install --upgrade numpy PYTHON 3: $ pip3 install --upgrade numpy