How to Check the NumPy Version

There are multiple ways to check the NumPy version; however, the easiest and PEP8 standard practice is to import numpy and use the numpy.__version__ attribute to get the exact version details.

This guide will look at various ways to get the NumPy version. Let us look at each of the approaches using code examples.

Check the NumPy version using __version__ attribute

The easiest and Pythonic way to get the NumPy version is by using the __version__ attribute. This is the standard way to check the version of any standard Python libraries.

import numpy




Get the Detailed Version of NumPy 

If you need detailed information on the NumPy version, then we can use np.version. The file gets generated using when we install the NumPy package, and it holds the version information such as version, short_version, full_version, etc.

import numpy as np



Note: The version, short_version, full_version will have the same value. If it's not a release version then the git_revision is added to the version and full_version.

Get the NumPy version using pip3

We can use the pip3 command to get the NumPy version. There are multiple ways to get the NumPy version using the pip command. 

The pip3 list command will list all the packages installed in your system or virtual environment.

pip3 list


numpy              1.21.6 
openpyxl           3.0.10
pandas             1.1.5

Instead of listing all the packages, you can find the NumPy package by using the command

>> pip3 list | FINDSTR numpy
numpy              1.21.6

On Linux

$ pip list | grep numpy
numpy              1.21.6

The second approach is to use the pip3 show command. It will provide complete information(version, author, installation path, license, etc.) on NumPy if installed on your machine or virtual environment.

pip3 show numpy


Name: numpy
Version: 1.21.6
Summary: NumPy is the fundamental package for array computing with Python.
Author: Travis E. Oliphant et al.
License: BSD
Location: c:\users\m1014107\appdata\local\programs\python\python37\lib\site-packages
Required-by: pandas

The third approach is to use pip3 freeze to get any Python package version without opening the Python shell.

>> pip freeze | FINDSTR 'numpy'

On Linux

$ pip freeze | grep 'numpy'

Verify the NumPy version on Anaconda Distribution.

We can get the NumPy version in the Anaconda distribution using the conda command. Open the Anaconda prompt and type the below command.

conda list numpy


# Name                    Version                   Build  Channel
numpy                     1.21.6           py38h34a8a5c_0
numpy-base                1.21.6           py38haf7ebc8_0
numpydoc                  1.1.6              pyhd3eb1b0_1
conda list | grep numpy


numpy                     1.21.6           py38h7241aed_0
numpy-base                1.21.6           py38h6575580_1
numpydoc                  1.1.6                      py_0

The other alternate way is to use the command line and print the NumPy version, as shown below.

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




There are multiple ways to check the NumPy version; the Pythonic and PEP8 standard ways are to use the numpy.__version__ attribute. Alternatively, we can also use the pip3 command to get the Python version.

Leave a Reply

Your email address will not be published. Required fields are marked *

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

You May Also Like