Before you can start using NumPy, you need to install it using Python’s package manager: pip
.
Prerequisites
- Python 3.6 or higher must be installed on your system.
- pip (Python’s package installer) must be available in your system path.
Step-by-Step Installation Guide
Step 1. Check if Python and pip are installed
Open your terminal or command prompt and run the following commands:
python --version
pip --version
This will show the installed Python and pip versions. If not found, download Python from python.org and make sure to check the box "Add Python to PATH" during installation.
Step 2. Install NumPy using pip
Once Python and pip are available, install NumPy by running:
pip install numpy
This will download and install the latest version of NumPy from the Python Package Index (PyPI).
Step 3. Verify the Installation
To verify that NumPy has been successfully installed, open a Python shell and run:
import numpy as np
print(np.__version__)
If the installation was successful, this will print the installed version of NumPy (e.g., 1.26.0
).
Troubleshooting Tips
- Command not found? Ensure Python and pip are properly installed and added to your system's PATH.
- Permission errors? Try using
pip install --user numpy
or run the command as administrator. - Using a virtual environment? Activate it before installing NumPy to isolate packages.
Optional: Install with Jupyter & SciPy stack
If you plan to use NumPy with Jupyter Notebooks or for data science workflows, you can install it with other scientific libraries:
pip install numpy scipy matplotlib jupyter
You’ve successfully installed NumPy.