Easy Tutorial
❮ Numpy Array Creation Numpy Arithmetic Operations ❯

NumPy Installation

The official Python distribution does not include the NumPy module.

We can use the following methods to install it.

1. Using Existing Distributions

For many users, especially on Windows, the easiest method is to download one of the following Python distributions, which include all the key packages (including NumPy, SciPy, matplotlib, IPython, SymPy, and other packages that come with the Python core):


2. Installing with pip

The simplest way to install NumPy is to use the pip tool:

pip3 install --user numpy scipy matplotlib

The --user option ensures that the installation is limited to the current user, rather than being written to the system directory.

By default, the installation uses a foreign route, which is too slow. We can use Tsinghua's mirror:

pip3 install numpy scipy matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple

Installation on Linux

Ubuntu & Debian

sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose

CentOS/Fedora

sudo dnf install numpy scipy python-matplotlib ipython python-pandas sympy python-nose atlas-devel

Mac System

The Homebrew package for Mac systems does not include NumPy or other scientific computing packages, so you can install them using the following method:

pip3 install numpy scipy matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple

Installation Verification

To test if the installation was successful:

>>> from numpy import *
>>> eye(4)
array([[1., 0., 0., 0.],
       [0., 1., 0., 0.],
       [0., 0., 1., 0.],
       [0., 0., 0., 1.]])

from numpy import * imports the numpy library.

eye(4) generates a diagonal matrix.

❮ Numpy Array Creation Numpy Arithmetic Operations ❯