How to Install Numpy?
Numpy is one of the most famous python libraries among data analysts and scientists. It is primarily used for scientific and mathematic computing. In python, packages/libraries like numpy, matplotlib, scipy, etc. are nothing but an extension module. So, installing a package is more or less similar to downloading its script and using it as a header/extension file.
Package Installer for Python(pip) is used for installing all python packages. We can check if pip is already installed on our system by typing [pip –version] on command prompt. Most of the time pip gets installed at the time of python installation. If it’s not already installed, you should download it from PyPI (Python Package Index), as we will be using it for downloading various python libraries. In this post, we will be learning to Install the NumPy package on MAC, Windows 10 and Ubuntu operating systems.
Installation of NumPy on Different Operating Systems
Here, we will see the installation of NumPy on different operating systems:
A. Install NumPy on Mac Operating System
Step 1: Open Terminal. We can open the terminal in MAC as follows:
- Go to the Menubar
- Select Go on the menu
- Select Utilities from the drop-down menu
- Select the Terminal from the searched results
Go → Utilities → Terminal
Step 2: Check if you have python installed on your system or not. You can check this by typing “Python” on the terminal. It will give you the version of python installed on your system. MAC operating system usually has already installed a python package in it.
Step 3: Open a new terminal as mentioned in step 1. Now, we will be installing the Numpy library, using the following command:
pip install numpy
This command will automatically start downloading and installing the numpy package.
Step 4: Now, let’s try to import numpy library to check if it has been successfully installed or not. We can use the following command to import numpy and use it in our programs. Write python on your terminal to create a python environment.
Python
Now, import numpy using this:
import numpy as np
This shows that we have successfully installed numpy in the MAC operating system. Now, we can use any of its classes and functions by creating a numpy object like np.array(), np.sum() or anything.
B. Install Numpy on Windows Operating System
Step1: Open command prompt. You can open the command prompt in Windows by searching in the taskbar, present in the bottom of your desktop.
Step 2: Check if you have python installed on your system or not. You can check this by typing “Python ” on the terminal. It will give you the version of python installed on your system.
Step 3: Open a new command prompt as mentioned in step 1. Now, we will be installing the Numpy library, using the following command:
pip install numpy
This command will automatically start downloading and installing the numpy package.
Step 4: Now, let’s try to import numpy library to check if it has been successfully installed or not. We can use the following command to import numpy and use it in our programs. Write python on your terminal to create a python environment.
Python
Now, import numpy using this:
import numpy as np
We have successfully installed numpy in the Windows operating system. Now, we can use any of its classes and functions by creating a numpy object like np.array(), np.sum() or anything.
C. Install Numpy on Ubuntu Operating System
Python is by default present on Ubuntu operating systems. So, we don’t need to install python here. But, this already installed python package does not come with pip, which is essential for installing any python package. Hence, we have to start by first downloading pip.
Step 1: Open command prompt. We can open the command prompt in ubuntu as follows:
- Open the Dash by clicking the Ubuntu icon in the upper-left
- Type “Terminal” on the search bar
- Select the Terminal from the searched results
Step 2: Install pip by using the following command,
sudo apt-get install python-pip
Once, we have successfully installed pip, we can move on to install numpy. This command will automatically start downloading and installing the pip package, without giving any dependency errors in the Ubuntu operating system.
Step 3: Open a new command prompt as mentioned in step 1. Now, we will be installing the Numpy library, using the following command:
sudo pip install numpy
This command will automatically start downloading and installing the numpy package, without giving any dependency errors in the Ubuntu operating system.
Step 4: Now, let’s try to import the numpy library to check if it has been successfully installed or not. We can use the following commands to import numpy and use it in our programs. Write python on your terminal to create a python environment.
Python
Now, import numpy using this:
import numpy as np
This command will successfully installed numpy in the Ubuntu(or any similar Linux) operating system. Now, we can use any of its classes and functions by creating a numpy object like np.array(), np.sum() or anything.
Conclusion – Install NumPy
We have successfully installed numpy across Mac, Windows, and Ubuntu operating systems. Numpy is a python extension module that is used for scientific and mathematical computations. As a data scientist or data analyst, you will most probably come across this module in your career. Also, this post is particularly made for numpy installations, but we can use the same method to download other python packages, like scipy, matplotlib, pandas, etc.
Recommended Articles
This is a guide to Install NumPy. Here we discuss how to install a numpy on different operating systems i.e. mac, windows, and, ubuntu. You may also look at the following articles to learn more –