The Wayback Machine - https://web.archive.org/web/20240613121536/https://www.geeksforgeeks.org/how-to-install-numpy-on-windows/
Open In App

How to Install Numpy on Windows?

Last Updated : 09 Jun, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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:

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:

instaling numpy using pip

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? – FAQ

How do I install NumPy?

You can install NumPy by using the pip package installer. Open your command prompt or terminal and run the following command: pip install numpy. This will download and install the latest version of NumPy from PyPI.

Do I need to install any dependencies for NumPy?

NumPy has a few dependencies, such as the Python development headers and a C compiler. However, when you install NumPy using pip, it automatically handles the dependencies for you.

Can I install a specific version of NumPy?

Yes, you can install a specific version of NumPy by specifying the version number in the pip install command. For example, to install version 1.19.5, you would run: pip install numpy==1.19.5.

I encountered an error related to building or compiling NumPy. What should I do?

Building NumPy from source requires certain development tools. On Windows, you might need to install Microsoft Visual C++ Build Tools. On macOS, you may need to install the Xcode Command Line Tools. On Linux, you may need to install the build-essential package. Refer to the NumPy documentation for detailed instructions based on your operating system.


Previous Article
Next Article

Similar Reads

How to Install the Windows Subsystem for Linux on Windows 11?
As a programmer, it is very important to test software on multiple platforms. However, it can be very tedious and inefficient to use multiple virtual machines to achieve the same. Thankfully, this process can be simplified if you are using Windows and wish to run a Linux distribution - with WSL. WSL, or Windows Subsystem for Linux, lets developers
2 min read
How to Download and Install Windows Movie Maker on Windows 10?
Movie Maker video is one of the best video editors available on the Microsoft store itself and is absolutely free. Movie maker video editor is a single-OS software, i.e. it works only in windows, and not on macOS, and Linux. Movie maker has more than 10 million users worldwide. Some of the very cool features of movie maker video editors are that th
2 min read
How to Install NumPy on MacOS | Easy NumPy Installation
In this article, we will learn how to install NumPy on MacOS. NumPy is a library for the Python programming language, that adds support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays. NumPy Installation in MACPython's NumPy library can be installed on M
2 min read
How to disable superfetch in windows 10 or windows 11?
Windows Vista introduced the Superfetch (SysMain) capability, which is still a part of the Windows operating system. It is a built-in service designed to speed up startup times and enhance performance by preloading frequently used apps in RAM. It was, however, primarily developed for older PCs. For contemporary PCs running Windows 10 and Windows 11
4 min read
How to Upgrade From Windows 10 to Windows 11 For Free?
Windows 11 is a very popular operating system by Microsoft. Windows 11 is free for Windows 10 PC that meet some minimum hardware requirements. There is no need to spend money on a brand-new computer when you can upgrade to Windows 11 for free. Besides this, Microsoft officially announced that existing PCs (original versions) will be offered to upgr
5 min read
Python | Numpy numpy.resize()
With the help of Numpy numpy.resize(), we can resize the size of an array. Array can be of any shape but to resize it we just need the size i.e (2, 2), (2, 3) and many more. During resizing numpy append zeros if values at a particular place is missing. Parameters: new_shape : [tuple of ints, or n ints] Shape of resized array refcheck : [bool, optio
2 min read
Python | Numpy numpy.transpose()
With the help of Numpy numpy.transpose(), We can perform the simple function of transpose within one line by using numpy.transpose() method of Numpy. It can transpose the 2-D arrays on the other hand it has no effect on 1-D arrays. This method transpose the 2-D numpy array. Parameters: axes : [None, tuple of ints, or n ints] If anyone wants to pass
2 min read
Python | Numpy numpy.ndarray.__lt__()
With the help of numpy.ndarray.__lt__() method of Numpy, We can find that which element in an array is less than the value which is provided in the parameter. It will return you numpy array with boolean type having only values True and False. Syntax: ndarray.__lt__($self, value, /) Return: self<value Example #1 : In this example we can see that
1 min read
Python | Numpy numpy.ndarray.__gt__()
With the help of numpy.ndarray.__gt__() method of Numpy, We can find that which element in an array is greater then the value which is provided in the parameter. It will return you numpy array with boolean type having only values True and False. Syntax: ndarray.__gt__($self, value, /) Return: self>value Example #1 : In this example we can see th
1 min read
Python | Numpy numpy.ndarray.__le__()
With the help of numpy.ndarray.__le__() method of Numpy, We can find that which element in an array is less than or equal to the value which is provided in the parameter. It will return you numpy array with boolean type having only values True and False. Syntax: ndarray.__le__($self, value, /) Return: self<=value Example #1 : In this example we
1 min read