NumPy belongs in the same Python environment that runs the project, notebook, or script. pip is the environment-based installer for Python projects that already use Python and do not need Conda or a project manager such as uv.
A local venv directory keeps the interpreter, pip, and the NumPy install together. Running python -m pip after activation ties the installer to the active interpreter instead of whichever pip command appears first on PATH.
A finished setup should show pip coming from .venv, report a NumPy version, and create a small array. Importing NumPy and executing array code catch mismatched interpreters and extension loading failures before notebooks, scripts, or IDEs depend on the environment.
Related: Install with uv
Related: Install with Conda
Related: Fix import errors
Steps to install NumPy with pip:
- Open a terminal in the project directory with Python 3 available.
If python3 -m venv reports that ensurepip or venv is missing on Debian or Ubuntu, install the distribution's python3-venv package, then rerun the virtual environment command.
- Create a virtual environment in the project directory.
$ python3 -m venv .venv
On Windows, use py -m venv .venv.
- Activate the virtual environment.
$ . .venv/bin/activate
On Windows, run .venv\Scripts\activate from the project directory.
- Confirm that pip belongs to the active virtual environment.
$ python -m pip --version pip 25.1.1 from /home/user/project/.venv/lib/python3.14/site-packages/pip (python 3.14)
The path should include .venv. A different path means the shell is not using the project environment.
- Install NumPy with pip.
$ python -m pip install numpy Collecting numpy ##### snipped ##### Successfully installed numpy-2.5.0
pip downloads the current compatible wheel from PyPI when one is available. The exact version changes as NumPy releases new packages for the active Python version and platform.
- Confirm that Python can import NumPy.
$ python -c "import numpy as np; print(np.__version__)" 2.5.0
The version may differ when PyPI has a newer compatible NumPy release. Any traceback means the active interpreter still cannot import the installed package.
Related: Fix import errors - Run a small NumPy array calculation.
$ python -c "import numpy as np; print(np.arange(3).tolist())" [0, 1, 2]
The array output confirms that NumPy imports and executes basic array code inside the same environment.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.