Installing Numpy on Windows

Below are the ways by which we can install NumPy on Windows and later on import Numpy in Python:

  • Using Conda
  • Using PIP

Install Numpy Using Conda

If you want the installation to be done through conda, you can use the below command:

conda install -c anaconda numpy

You will get a similar message once the installation is complete

Make sure you follow the best practices for installation using conda as:

  • Use an environment for installation rather than in the base environment using the below command:
conda create -n my-env
conda activate my-env

Note: If your preferred method of installation is conda-forge, use the below command:

conda config --env --add channels conda-forge

Installing Numpy For PIP Users

Users who prefer to use pip can use the below command to install NumPy:

pip install numpy

You will get a similar message once the installation is complete:

Now that we have installed Numpy successfully in our system, let’s take a look at few simple examples.

Example of Numpy

In this example, a 2D NumPy array named arr is created, and its characteristics are demonstrated: the array type, number of dimensions (2), shape (2 rows, 3 columns), size (6 elements), and the data type of its elements (int64).

Python
# Python program to demonstrate
# basic array characteristics
import numpy as np

# Creating array object
arr = np.array( [[ 1, 2, 3],
                [ 4, 2, 5]] )

# Printing type of arr object
print("Array is of type: ", type(arr))

# Printing array dimensions (axes)
print("No. of dimensions: ", arr.ndim)

# Printing shape of array
print("Shape of array: ", arr.shape)

# Printing size (total number of elements) of array
print("Size of array: ", arr.size)

# Printing type of elements in array
print("Array stores elements of type: ", arr.dtype)

Output:

Array is of type:  
No. of dimensions: 2
Shape of array: (2, 3)
Size of array: 6
Array stores elements of type: int64

How to Install Numpy on Windows?

Python NumPy is a general-purpose array processing package that provides tools for handling n-dimensional arrays. It provides various computing tools such as comprehensive mathematical functions, and linear algebra routines. NumPy provides both the flexibility of Python and the speed of well-optimized compiled C code. Its easy-to-use syntax makes it highly accessible and productive for programmers from any background. In this article, we will see how to install NumPy as well as how to import Numpy in Python.

Pre-requisites:

Similar Reads

Installing Numpy on Windows

Below are the ways by which we can install NumPy on Windows and later on import Numpy in Python:...

How to Install Numpy on Windows? – FAQ

How do I install NumPy?...