How to Install Scikit-Learn on MacOS?
Last Updated :
30 Sep, 2021
In this article, we will learn how to install Scikit-Learn in Python on MacOS. The scikit-learn is a Python module for machine learning built on top of SciPy and is distributed under the 3-Clause BSD license.
Installation:
Method 1: Using pip to install Scikit-Learn Package
Follow the below steps to install the Scikit-Learn package on macOS using pip:
Step 1: Install the latest Python3 in MacOS
Step 2: Check if pip3 and python3 are correctly installed.
python3 --version
pip3 --version
Step 3: Upgrade your pip to avoid errors during installation.
pip3 install --upgrade pip
Step 4: Enter the following command to install Scikit-Learn using pip3.
pip3 install scikit-learn
Method 2: Using setup.py to install Scikit-Learn
Follow the below steps to install the Scikit-Learn package on macOS using the setup.py file:
Step 1: Download the latest source package of Scikit-Learn for python3 from here.
curl https://files.pythonhosted.org/packages/e1/4d/15c3542a17eebf61e48bd71dc55b5f3b5031f1cd0dc4aad1ff9ac9651e49/scikit-learn-1.0.tar.gz > Scikit-Learn.tar.gz
Step 2: Extract the downloaded package using the following command.
tar -xzvf Scikit-Learn.tar.gz
Step 3: Go inside the folder and Enter the following command to install the package.
Note: Install Cython via pip before installing the module via setup.py
pip3 install Cython
Note: You must have developer tools for XCode MacOS installed in your system
cd scikit-learn-1.0
python3 setup.py install
Verifying Scikit-Learn installation on macOS:
Make the following import in your python terminal to verify if the installation has been done properly:
import sklearn
If there is any error while importing the module then is not installed properly.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...