How to Check Numpy Version on Mac, Linux, and Windows

To check a numpy version on mac, linux, and windows platforms, write the numpy.__version__ code and run the Python file. It will return the current version of numpy installed on your machine.

There are the following alternate methods that can help you to check the numpy version.

  1. Use the pip list or pip3 list command.
  2. From the command line type: python3 -c “import numpy; print(numpy.__version__)”
  3. From command line type: pip3 freeze | grep ‘numpy’ or pip freeze | grep ‘numpy
  4. From command line type: pip3 show numpy or pip show numpy

Checking the Numpy version using numpy._version_

Create a file called app.py and write the following two lines of code inside that file.

import numpy

print(numpy.__version__)

Output

1.23.5

The latest version at the time of writing this tutorial is 1.23.5. Yours might be the oldest or latest, depending on your machine’s installation time.

Getting the numpy version using the pip3 list command

You can use the pip3 list command to list the packages, and if Numpy is installed in your system, it will appear with its version. For example, if you use Python3, you can use the following command.

pip3 list

Output

pip3 list
numpy 1.23.5
oauthlib 3.1.0
opt-einsum 3.2.1
pandas 1.0.3
pip 20.1

You can use the following command if you are using Python 2 or Python.

pip list

Printing the Numpy version

Print the Numpy version in the command line. Type the following command.

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

Output

1.23.5

If you use Python 2.x, you can use the following command.

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

Using the grep command to get the numpy version

Type the following command.

pip3 freeze | grep 'numpy'

See the output.

pip3 freeze | grep 'numpy'
numpy==1.18.3

If you are using Python 2.x, then use the following command.

pip freeze | grep 'numpy'

Using pip3 show command

Type the following command.

pip3 show numpy

Output

pip3 show numpy
Name: numpy
Version: 1.18.3
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location:/Library/Frameworks/Python.framework/Versions/3.8/python3.8/site-packages
Requires:
Required-by: tensorflow, tensorboard, opt-einsum, Keras-Preprocessing, h5py, 
             scipy, scikit-learn, pandas, matplotlib

Checking the Numpy version on Anaconda Distribution

To check a numpy version on the Anaconda navigator, use the command conda list | grep numpy command.

conda list | grep numpy

See the output.

conda list | grep numpy
numpy 1.18.1 py37h7241aed_0
numpy-base 1.18.1 py37h6575580_1
numpydoc 0.9.2 py_0

Conclusion

The easy and fastest way to check the current numpy version is by adding numpy.__version__ code and run the Python file.

Related posts

How to check a Python version

How to update pip

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.