How to Check Numpy Version in Your Python Script?

check numpy version

Check numpy Version: This article will detail the different methods to check the version of NumPy installed on your Python environment.

Numpy Python Module

The Python module numpy is a very powerful mathematical library that is used to perform various analyses and many packages are dependent on numpy (such as the Pandas module). It is often used by data analysts or data scientists because it can be integrated with a large number of databases.

In many cases, it will be necessary to check the numpy version to avoid possible conflicts that many packages depend on.

This article will explain how to determine which version of numpy is installed on your machine.

Check numpy Version With __version__ Attribut

As in a large majority of python packages, it is possible to get the version of numpy with the __version__ attribute.

# __version__ attribut

import numpy as np




Get detailed information using np.version

Another way to check the NumPy version running in your script is to use the np.version.version attribute

To print the version, simply use the print() function. Here is the code that does it:

# np.version.version attribut

import numpy as np




numpy.version can also provide you with other information about your numpy version such as :

# np.version.version attribut

import numpy as np

print("Short Version: " + np.version.short_version)

print("Full Version: " + np.version.full_version)

print("Git Revision: " + np.version.git_revision)

print("Release Version: " + str(np.version.release))


Short Version: 1.21.2
Full Version: 1.21.2
Git Revision: 2fe48d2d98a85c8ea3f3d5caffd952ea69e99335
Release Version: True

We can see that in the previous example, the attributes version, short_version and full_version contain the same value.

Check numpy Version using PIP

pip is the package installer for Python. It is often used to install, upgrade or to get the version of a package.

So we can also use the pip show command to get information (including its version.) about a package.

Here is how to proceed for the numpy module:

(venv) C:\Users\Pycharm\project>pip show numpy
Name: numpy
Version: 1.21.2
Summary: NumPy is the fundamental package for array computing with Python.
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location: c:\users\pycharm\project\venv\lib\site-packages
Required-by: pandas

You can also see the packages that are dependent on numpy.

The pip list command allows to list all the packages installed on the python environment and their version:

(venv) C:\Users\Pycharm\project>pip list
Package            Version
------------------ ---------
certifi            2021.5.30
charset-normalizer 2.0.4
idna               3.2
numpy              1.21.2
pandas             1.3.2

Final Words

This tutorial explained how to get the version of numpy currently installed on your python environment. If you have any problems installing NumPy, don’t hesitate to tell me in comments !

I also wrote a tutorial to install a specific version of a library: pip install specific version.

Back to Python Menu

Categorized as Python

By ayed_amira

I'm a data scientist. Passionate about new technologies and programming I created this website mainly for people who want to learn more about data science and programming :)

Leave a comment

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