Open In App

How to Install NumPy on MacOS | Easy NumPy Installation

Last Updated : 02 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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 MAC

Python’s NumPy library can be installed on Mac using the pip installer and using the setup.py file.

We have explained the 2 methods with easy-to-follow steps. We will also look at how to verify the clean installation of NumPy.

Method 1: Using pip to install the NumPy Package

Follow the below steps to install the Numpy package on macOS using pip:

Step 1: Install the latest Python3 in MacOS

Install latest Python version

Step 2: Check if pip3 and python3 are correctly installed.

python3 --version
pip3 --version

checking python and pip version in macos

Step 3: Upgrade your pip to avoid errors during installation.

pip3 install --upgrade pip

upgrading pip in macos

Step 4: Enter the following command to install Numpy  using pip3.

pip3 install numpy 

installing Numpy package on macOS using pip

Method 2: Using setup.py to install Numpy 

Follow the below steps to install the Numpy package on macOS using the setup.py file:

Step 1: Download the latest source package of Numpy for python3 from here.

curl https://files.pythonhosted.org/packages/3a/be/650f9c091ef71cb01d735775d554e068752d3ff63d7943b26316dc401749/numpy-1.21.2.zip > numpy.tar.gz


downloading the source package for Numpy in macos

Step 2: Extract the downloaded package using the following command.

tar -xzvf numpy.tar.gz

extracting the numpy.tar.gz file in macos

Step 3: Go inside the folder and Enter the following command to install the package.

Note: You must have developer tools for XCode MacOS installed in your system

cd numpy-1.21.2
python3 setup.py install

installing Numpy on macOS using the setup.py file

Verifying Numpy installation on macOS:

Try NumPy import in your python terminal to verify if the installation has been done properly:

import numpy

Verifying Numpy installation on macOS

If there is any error while importing the module then is not installed properly.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads