---
title: "How to Install scikit-learn (sklearn) on Windows, macOS, and Linux"
description: "Safely install scikit-learn on Windows, macOS, or Linux with pip or conda to avoid dependency issues."
url: "https://iproyal.com/blog/how-to-install-scikit-learn/"
---

- [EN - English](https://iproyal.com/)
   
  [中文 - Chinese](https://iproyal.cn/)

[Book a Demo](https://iproyal.com/request-a-demo/) [Create Account](https://dashboard.iproyal.com/register/) [Create Account](https://dashboard.iproyal.com/register/) [Login](https://dashboard.iproyal.com/login/) [Login](https://dashboard.iproyal.com/login/)

[Book a Demo](https://iproyal.com/request-a-demo/)

[Back to blog](https://iproyal.com/blog/)

# How to Install scikit-learn (sklearn) on Windows, macOS, and Linux

[Justas Vitaitis](https://iproyal.com/blog/authors/justas-vitaitis/)

[Last updated - August 6, 2026 ‐ 6 min read](https://iproyal.com/blog/authors/justas-vitaitis/)

[Tutorials](https://iproyal.com/blog/category/tutorials/)

## Key Takeaways

- Use virtual environments to isolate your dependencies and prevent library updates from breaking your code.

- Use *pip* (which defaults to pre-compiled wheels) or *conda-forge* to avoid compiler errors during installation.

- Verify your setup immediately by running *import sklearn* to ensure the underlying math libraries are linked correctly.

As a core piece of the data science toolkit, *scikit-learn* (sklearn) requires a clean environment setup to function correctly. Using *pip* or *conda* inside a virtual environment is the most reliable way to prevent dependency conflicts as your projects grow.

This guide covers how to install prerequisites, set up virtual environments, test your installation, and troubleshoot common configuration errors.

## scikit-learn System Requirements and Prerequisites

Before typing any installation commands, you need to ensure your base system has the right foundational pieces in place: a modern Python environment and a compatible Python interpreter.

As of 2026, you need Python 3.11 or newer to install *scikit-learn.* To check your current version, open up the terminal and run:

```javascript
python --version
```

Modern package managers handle dependency resolution automatically. When you install *scikit-learn, pip* or *conda* will automatically download the necessary libraries:

- **NumPy&#x20;**&#x68;andles heavy numerical arrays
- **SciPy&#x20;**&#x6D;anages advanced mathematical operations
- **joblib&#x20;**&#x74;akes care of parallel processing tasks
- **threadpoolctl&#x20;**&#x6C;imits thread usage to prevent CPU stalling
- **narwhals&#x20;**&#x70;rovides a lightweight DataFrame compatibility layer

Letting your package manager automatically resolve and install these dependencies ensures version compatibility and saves you from complex debugging.

## How to Set Up a Virtual Environment for scikit-learn

Installing libraries globally can cause dependency conflicts, and you may end up breaking one tool while updating the other. If you use a virtual environment, you get to isolate your dependencies so projects don’t interfere with each other.

### venv on Windows

Python’s standard library includes *venv,* allowing you to create environments directly from your terminal without third-party tools.

```javascript
python -m venv myenv
myenv\Scripts\activate
```

*(Note: If you are using PowerShell, use .\myenv\Scripts\Activate.ps1)*

### *venv* on macOS/Linux

Unix-based systems use a slightly different folder structure and activation command:

```javascript
python3 -m venv myenv
source myenv/bin/activate
```

### conda Environments

Conda is highly recommended for data science and machine learning because it manages both versions and underlying C/C++ binary libraries. As a result, it prevents compilation errors when installing complex packages.

```javascript
conda create -n myenv python=3.12
conda activate myenv
```

## How to Install scikit-learn With pip or conda

Once your virtual environment is active, the process for how to install sklearn is straightforward using either *pip* or *conda.*

### Install scikit-learn Using pip

Using *pip* fetches pre-compiled wheels from the Python Package Index (PyPI). It automatically installs the necessary mathematical dependencies without requiring you to compile anything from source.

```javascript
pip install scikit-learn
```

You can pin a specific version (e.g., *==1.9.0)* to ensure future environment rebuilds don't introduce breaking changes from library updates:

```javascript
pip install scikit-learn==1.9.0
```

### Install scikit-learn Using conda

If you’re using Anaconda or Miniconda, make sure you install from the community-driven *conda-forge* channel (it’s the recommended approach). *Conda-forge* is particularly useful if your project requires complex non-Python dependencies (like system-level libraries) alongside *scikit-learn.*

```javascript
conda install -c conda-forge scikit-learn
```

## Alternative scikit-learn Installation Methods

While virtual environments are the standard, you can also get *scikit-learn* through system package managers or pre-packaged distributions.

### OS-Level Package Managers (Linux)

While you can use OS-level package managers, we’d recommend against it. System repositories are often several versions behind, and installing Python modules and packages globally can conflict with your operating system's internal tools. But if you must use them:

- **Debian/Ubuntu.&#x20;***sudo apt install python3-sklearn*
- **Fedora.&#x20;***sudo dnf install python3-scikit-learn*

### Pre-Packaged Distributions

Scientific Python distributions like the full Anaconda package or WinPython come with *scikit-learn* pre-installed. These distributions provide a complete data science environment out of the box, so you bypass the need for manual installation entirely.

## scikit-learn Core and Optional Dependencies

The default installation includes the core libraries needed to run standard [machine learning ](https://iproyal.com/blog/web-scraping-machine-learning/)algorithms. To add plotting or advanced data frame support, you’ll need to install optional dependencies.

| **Core dependency** | **Role in the ecosystem** |
| - | - |
| NumPy | Powers the fundamental multi-dimensional array structures. |
| SciPy | Provides advanced linear algebra and sparse matrix routines. |
| joblib | Drives parallel computing features for faster model training. |
| threadpoolctl | Limits thread usage to prevent CPU stalling. |
| narwhals | Provides a lightweight DataFrame compatibility layer. |

Optional dependencies provide visualization and enhanced data handling:

- ***matplotlib&#x20;***&#x65;nables you to plot decision boundaries and performance metrics natively
- ***pandas&#x20;***&#x6C;ets you feed tabular structures directly into your pipelines without manual conversion
- ***seaborn&#x20;***&#x6D;akes generating visually appealing correlation matrices incredibly simple
- ***scikit-image&#x20;***&#x70;rovides image processing tools for preparing photographs or scans before classification

## How to Verify Your scikit-learn Installation

To verify your installation, you don’t need to [train a model ](https://iproyal.com/blog/best-llm-training-datasets/). Simply use *scikit-learn's* built-in utility to check the status of the *scikit-learn* library and all of its core dependencies.

You can run this command directly from your active terminal:

```javascript
python -m sklearn.show_versions
```

This will output a detailed list showing your operating system, your Python version, and the specific versions of *NumPy, SciPy, joblib,* and *threadpoolctl* that *scikit-learn* is currently using.

Once the output confirms your core libraries are present and correctly versioned, your environment is ready to use.

### Installing scikit-learn From Source or Nightly Builds

If you need an unreleased bug fix or want to contribute to the project, you must build *scikit-learn* directly from its source code. Building from source requires a C/C++ compiler and *Cython* installed on your system.

First, clone the repository via HTTPS and run an editable installation:

```javascript
git clone https://github.com/scikit-learn/scikit-learn.git
cd scikit-learn
pip install --verbose --no-build-isolation --editable .
```

### Using Nightly Builds

To access unreleased features without compiling from source, you can install the nightly wheels. Keep in mind that these builds are intended for testing and may contain bugs not present in stable releases.

You can install the nightly build using the scientific-python index:

```javascript
pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple scikit-learn
```

## Troubleshooting scikit-learn Installation Errors

Even with a proper setup, you might encounter installation errors. Here are a few common issues and how to resolve them:

- **Windows path limits.&#x20;**&#x57;indows users with deeply nested project folders might hit the OS's 260-character path limit. You can prevent extraction errors by enabling Long Paths in the Windows Registry.
- **Missing compilers.&#x20;**&#x49;f building from source, you must install Visual Studio Build Tools (Windows) or GCC (macOS/Linux) to avoid C++ compilation errors.
- **Version conflicts.&#x20;**&#x49;f Python imports an older version of *scikit-learn* than the one you just installed, you likely have a conflicting global installation. Uninstall the global package and ensure your virtual environment is activated.
- **Permission errors.&#x20;**&#x52;unning *pip install scikit-learn* globally on macOS or Linux can result in "permission denied" errors. Always ensure your virtual environment is active before installing.

If you encounter an undocumented error, checking the *scikit-learn* GitHub issues page is the best way to find community-tested workarounds.

## FAQ

Can I install scikit-learn without installing NumPy and SciPy manually?

Yes. Package managers like *pip* and *conda* automatically resolve and install all required dependencies, including NumPy and SciPy.

Is it safe to use the version of scikit-learn that comes with my Linux distribution?

It’s not recommended. System repositories are often outdated, and installing Python libraries globally can break your Linux distribution's internal tools. Always use a virtual environment instead.

How do I install multiple versions of scikit-learn on the same computer?

Create a separate virtual environment for each project, which isolates dependencies so you can run different versions of *scikit-learn* on the same machine without conflict.

Do I need GPU support or special hardware to use scikit-learn?

No. *Scikit-learn* is primarily designed for standard CPU processing, so no special hardware is required. However, modern versions do support GPU acceleration for certain estimators via the Array API if you choose to configure it.

How can I keep scikit-learn up to date in an existing project?

Run *pip install --upgrade scikit-learn* or *conda update scikit-learn.* Always check the release notes and test your code after upgrading, as major updates occasionally deprecate older functions.

[Create Account](https://dashboard.iproyal.com/)

[Author](https://iproyal.com/blog/authors/justas-vitaitis/)

[Justas Vitaitis](https://iproyal.com/blog/authors/justas-vitaitis/)

[Senior Software Engineer](https://iproyal.com/blog/authors/justas-vitaitis/)

Justas is a Senior Software Engineer with over a decade of proven expertise. He currently holds a crucial role in IPRoyal’s development team, regularly demonstrating his profound expertise in the Go programming language, contributing significantly to the company’s technological evolution. Justas is pivotal in maintaining our proxy network, serving as the authority on all aspects of proxies. Beyond coding, Justas is a passionate travel enthusiast and automotive aficionado, seamlessly blending his tech finesse with a passion for exploration.

[Learn More About Justas Vitaitis ](https://iproyal.com/blog/authors/justas-vitaitis/)[Meet all Writers](https://iproyal.com/blog/authors/)

Share on

### In This Article

- [scikit-learn System Requirements and Prerequisites](https://iproyal.com/blog/how-to-install-scikit-learn/#scikit-learn-System-Requirements-and-Prerequisites)
- [How to Set Up a Virtual Environment for scikit-learn](https://iproyal.com/blog/how-to-install-scikit-learn/#How-to-Set-Up-a-Virtual-Environment-for-scikit-learn)
- [How to Install scikit-learn With pip or conda](https://iproyal.com/blog/how-to-install-scikit-learn/#How-to-Install-scikit-learn-With-pip-or-conda)
- [Alternative scikit-learn Installation Methods](https://iproyal.com/blog/how-to-install-scikit-learn/#Alternative-scikit-learn-Installation-Methods)
- [scikit-learn Core and Optional Dependencies](https://iproyal.com/blog/how-to-install-scikit-learn/#scikit-learn-Core-and-Optional-Dependencies)
- [How to Verify Your scikit-learn Installation](https://iproyal.com/blog/how-to-install-scikit-learn/#How-to-Verify-Your-scikit-learn-Installation)
- [Troubleshooting scikit-learn Installation Errors](https://iproyal.com/blog/how-to-install-scikit-learn/#Troubleshooting-scikit-learn-Installation-Errors)
- [FAQ](https://iproyal.com/blog/how-to-install-scikit-learn/#FAQ)

Ready to get started?

[Register now](https://dashboard.iproyal.com/register/)

Data News in Your Inbox

No spam whatsoever, just pure data gathering news, trending topics and useful links. Unsubscribe anytime.

No spam. Unsubscribe anytime.

## Related articles

[View all](https://iproyal.com/blog/category/tutorials/)

[Tutorials](https://iproyal.com/blog/the-most-common-payment-processing-obstacles-and-solutions-for-saas-companies/)

## [The Most Common Payment Processing Obstacles and Solutions for SaaS Companies](https://iproyal.com/blog/the-most-common-payment-processing-obstacles-and-solutions-for-saas-companies/)

[Here are the most common payment processing obstacles SaaS companies face and the solution that helped us focus on growth and our services!](https://iproyal.com/blog/the-most-common-payment-processing-obstacles-and-solutions-for-saas-companies/)

[August 8, 2022](https://iproyal.com/blog/the-most-common-payment-processing-obstacles-and-solutions-for-saas-companies/)

[3 min read](https://iproyal.com/blog/the-most-common-payment-processing-obstacles-and-solutions-for-saas-companies/)

[Tutorials](https://iproyal.com/blog/easy-programmatic-seo-with-wordpress/)

## [Easy Programmatic SEO with WordPress](https://iproyal.com/blog/easy-programmatic-seo-with-wordpress/)

[Our fourth and final entry in the pSEO series explains how to combine programmatic SEO with WordPress using plugins or code snippets.](https://iproyal.com/blog/easy-programmatic-seo-with-wordpress/)

[March 30, 2023](https://iproyal.com/blog/easy-programmatic-seo-with-wordpress/)

[10 min read](https://iproyal.com/blog/easy-programmatic-seo-with-wordpress/)

[Tutorials](https://iproyal.com/blog/api-for-dummies-the-coders-and-no-coders-guide/)

## [API for Dummies — The Coder’s and No-coder’s Guide](https://iproyal.com/blog/api-for-dummies-the-coders-and-no-coders-guide/)

[Learn API basics with this guide for coders and non-coders. Discover the different components of an API call.](https://iproyal.com/blog/api-for-dummies-the-coders-and-no-coders-guide/)

[June 1, 2023](https://iproyal.com/blog/api-for-dummies-the-coders-and-no-coders-guide/)

[11 min read](https://iproyal.com/blog/api-for-dummies-the-coders-and-no-coders-guide/)
