In Python, NumPy is an important library available for scientific computing and mathematical purposes. Learn how easy it is to install NumPy on Windows 11 with PIP and Command Prompt (CMD) along with installing it on macOS and other Linux distributions.
NumPy is a 100% open-source project which comes for free! It includes the following:
- Different derived objects like masked arrays and matrices.
- Assortment of routines or fast operations on arrays which also include mathematical, logical, shape manipulation, sorting, selecting and Input/Output operations.
Why it is used the most and why it is so popular?
- It provides an array of objects which is 5x faster than the traditional lists.
- Ndarray which is one of the array objects in this provides you with many supporting functions so that working with it becomes easy.
- Arrays are most often used in data science in which both speed and resources are quite important.
The 2 reasons behind its Popularity:
- Compact, powerful and expressive syntax.
- You can manage your data in vectors, matrices and higher dimensional arrays.
History of NumPy
Jim Hugunin with contributions to many other developers created the ancestor of NumPy known as Numeric. After this, in 2005 Travis Oliphant created this by incorporating many features of competing Numarray into Numeric. After All these modifications made we got this project which is open-source and has plenty of contributors
It is written down in Python but many parts which require fast computations are written down in C/ C++.
Pros and Cons of Installing and Using NumPy
- Takes less space on your hard drive.
- Provide good runtime when compared with others.
- It created n-dimension arrays.
- It is best for data analysis and scientific uses.
- A great substitute for MATLAB, is OCTAVE as it provides with same functions.
- It provides support to vectorized operations such as elementwise addition and multiplication, computing Kronecker product and much more.
- It supports linear algebra.
Only 2 cons:
- Needs contiguous allocation of memory.
- Using nan in NumPy: it stands for “not a number”.
How to Install NumPy on Windows 11 via PIP, CMD and POP3 (3 Easy Steps)
If you do not know then by default you windows do not have Python. Therefore, you need to download the version required from python.org. Once done you can easily open the command prompt and then use pip to install it.
[email protected]:~# Pop3 install numpy [email protected]:~# Successfully installed numpy-1.x.x [email protected]:~# >>> import numpy as np To Install via PIP: [email protected]:~# Pip install numpy
How to Install NumPy on Apple macOS & Linux
To Install NumPy v2.7:
- In your, Macbook open the terminal and type python to get into the python prompt.
- After this to open the spotlight search press the command (⌘) + space bar. Type in the terminal and hit “enter”.
- Here, use the pip command in order to get the NumPy package.
[email protected]:~# Pip install numpy
- As it gets installed you need to type in python to have its prompt, you shall see that version is mentioned as well. All you need to do is use the import command in order to include NumPy package and then use. a shortcut can also be set for it.
To Install NumPy Version 3:
When you open the terminal as mentioned above in step 1, use the “pip3” command” to install it.
Have a note on that command being used Pip3 means we are working with version 3 of Python. Just keep it in your mind.
[email protected]:~# Pip3 install numpy [email protected]:~# Import numpy as ny
The above method has been verified to work on Apple M1 and M2 chip laptops.
Installing on Fedora and Ubuntu
You shall find python on this by default. All you have to do is use the pip command to install
[email protected]:~# Pip install numpy [email protected]:~# Pytho3 –m pip install numpy
On Ubuntu, by default, you shall find Python but the sad part pip is not installed. For a complete package simply visit python.org and install it by using the apt install command.
Now, as an alternate you can also install it and then install NumPy which is the easier of the two ways, didn’t understand? Let us explain
On the system, you shall need to have root privileges for this to work.
- In Ubuntu, you need to open a terminal.
- Then install pip and pip3 by using apt.
[email protected]:~# Apt install python-pip python-pip3y
NumPy is the most popular mathematical library for Python that is free! After following the above tutorial on installing NumPy on Windows 11, Mac and other Linux distros should be a breeze for you. The methods we have shared for the installation are performed with the use of PIP, POP3 and Apt which are the most common ways and reliably work as expected.