How to Install NumPy in Python

What you’ll build or solve

You’ll install NumPy into the right Python environment and confirm Python can import it.

When this approach works best

Installing NumPy works best when you want to:

  • Work with arrays and numeric data in scripts, notebooks, or small data projects.
  • Follow a course or tutorial that expects NumPy for math, statistics, or plotting.
  • Add NumPy to a project without affecting other projects on your machine.

This is a bad idea when you keep installing packages globally for every project. Use a virtual environment for project work so dependencies stay isolated.

Prerequisites

  • Python 3 installed
  • Access to a terminal (Command Prompt, PowerShell, or a macOS/Linux terminal)

Step-by-step instructions

1) Install NumPy with pip

Use python -m pip so pip matches the Python you plan to run.

Option A: Install NumPy (most common)

python-m pip install numpy

Option B: If your system uses python3

python3-m pip install numpy

Option C: Install a specific version

python-m pip install"numpy==1.26.4"

What to look for: If you see “Requirement already satisfied,” NumPy is already installed in that environment.


2) Confirm the install worked

Import NumPy and print its version.

python-c"import numpy as np; print(np.__version__)"

What to look for:

ModuleNotFoundError: No module named 'numpy' usually means you installed NumPy for a different Python version than the one you are running.


3) Install in a virtual environment (recommended for projects)

After creating and activating a virtual environment, install NumPy there:

python-m pip install numpy

Confirm you are inside the virtual environment:

python-c"import sys; print(sys.executable)"

The path should point inside your venv folder (often .venv).


Examples you can copy

Example 1: Install and verify in one go

python-m pip install numpy
python-c"import numpy as np; print(np.__version__)"

Example 2: Upgrade NumPy

python-m pip install--upgrade numpy

Example 3: Install from a requirements.txt

python-m pip install-r requirements.txt

Example 4: Verify which Python and pip you are using

python-c"import sys; print(sys.executable)"
python-m pip--version

This helps confirm that both commands refer to the same interpreter.


Example 5: Install in an already activated virtual environment

python-m pip install numpy
python-c"import numpy as np; print(np.__version__)"
python-c"import sys; print(sys.executable)"

Common mistakes and how to fix them

Mistake 1: Using pip install numpy and hitting the wrong Python version

What you might do

pip install numpy
python-c"import numpy"

Why it breaks

pip can belong to a different interpreter than python.

Corrected approach

python-m pip install numpy
python-c"import numpy as np; print(np.__version__)"

Mistake 2: Installing NumPy in one environment, then running Python in another

What you might do

  • Install NumPy in a virtual environment
  • Run python outside that environment and try to import NumPy

Why it breaks

Each environment has its own site-packages, so the import can fail.

Corrected approach

Activate the environment you installed into, then confirm the interpreter path:

python-c"import sys; print(sys.executable)"
python-c"import numpy as np; print(np.__version__)"

Troubleshooting

If you see ModuleNotFoundError: No module named 'numpy', do this:

python-c"import sys; print(sys.executable)"
python-m pip install numpy

Make sure you install NumPy with the same interpreter you run.

If you see pip: command not found, run pip through Python:

python-m pip install numpy

If you see permission errors on macOS/Linux, either use a virtual environment or install for your user:

python-m pip install--user numpy

If installation is slow or fails, upgrade pip, then retry:

python-m pip install--upgrade pip
python-m pip install numpy

If you are on Windows and python opens the Store, use the launcher:

py-m pip install numpy
py-c"import numpy as np; print(np.__version__)"

Quick recap

  • Install with python -m pip install numpy
  • Verify with python -c "import numpy as np; print(np.__version__)"
  • Use a virtual environment for project installs, then install NumPy inside it
  • If imports fail, check sys.executable to confirm which Python you are running