Cómo instalar NumPy en Ubuntu 20.04 | Ubuntu 20.10
NumPy es una biblioteca de Python utilizada para la computación científica. Ofrece lo siguiente y mucho más.
- objeto de matriz multidimensional
- arreglos y matrices enmascarados
- manipulación de formas
- clasificación
- seleccionando
- transformadas discretas de Fourier
- álgebra lineal básica
- operaciones estadisticas basicas
- simulación aleatoria
En este tutorial aprendemos a instalar NumPy en Ubuntu 20.04 .
Instalar pip en Ubuntu
Pip es la herramienta oficial para administrar paquetes de python. Ayuda a instalar, desinstalar y actualizar un paquete específico a la última versión. Los desarrolladores encuentran esta utilidad muy útil cuando se trata de instalar todo el paquete de dependencias de un proyecto.
Descargue pip para python 2 usando el comando wget:
$ wget https://bootstrap.pypa.io/2.7/get-pip.py -O get-pip27.py
Now to Install pip run the following command:
$ sudo python2 get-pip27.py
As for the installation of pip for python3, the process is the same.
Download the script for pip:
$ wget https://bootstrap.pypa.io/get-pip.py -O get-pip.py
To Install pip for python 3, type:
$ sudo python3.9 get-pip.py
Install NumPy on Ubuntu
The pip utility helps to install NumPy for both versions of python. As for the python 2.x version, the following command installs the NumPy package.
$ python2 -m pip install numpy
The -m
option helps to use a specific python package; in our case pip.
On success, the following should be displayed on your console.
Collecting numpy Downloading numpy-1.16.6-cp27-cp27mu-manylinux1_x86_64.whl (17.0 MB) |████████████████████████████████| 17.0 MB 12.2 MB/s Installing collected packages: numpy WARNING: The scripts f2py, f2py2 and f2py2.7 are installed in '/home/computerfreaks/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed numpy-1.16.6
For the installation of numpy on python 3, run the following command.
$ python3.9 -m pip install numpy
Verify the installation.
$ python3.9 -m pip show numpy
The option show helps to identify an installed python package.
$ python2 -m pip show numpy
Import numpy from the python interactive shell
The following command imports the library under the name of np. It works both for python 2 and python 3.
import numpy as np
Upgrade NumPy to the latest version
The pip utility has an option that helps to upgrade an installed package to the latest
version.
To upgrade numpy for python 2, type:
$ pip2 install --upgrade numpy
For python 3 run the following command:
$ pip3 install --upgrade numpy
Final thoughts
Through this article, you learned how to properly install the numpy package for both python 2 and python 3. You also learned how to upgrade the numpy package to the latest version.