6.3. Installing NumPy¶
Before NumPy’s functions and methods can be used, NumPy must be installed. Depending on which distribution of Python you use, the installation method is slightly different.
6.3.1. Install NumPy on Anaconda¶
If you installed the Anaconda distribution of Python, NumPy comes pre-installed and no further installation steps are necessary.
If you use a version of Python from python.org or a version of Python that came with your operating system, the Anaconda Prompt and conda or pip can be used to install NumPy.
6.3.2. Install NumPy with the Anaconda Prompt¶
To install NumPy, open the Anaconda Prompt and type:
> conda install numpy
Type y
for yes when prompted.
6.3.3. Install NumPy with pip¶
To install NumPy with pip, bring up a terminal window and type:
$ pip install numpy
This command installs NumPy in the current working Python environment.
6.3.4. Verify NumPy installation¶
To verify NumPy is installed, invoke NumPy’s version using the Python REPL. Import NumPy and call the .__version__
attribute common to most Python packages.
import numpy as np
np.__version__
'1.21.2'
A version number like '1.16.4'
indicates a successful NumPy installation.