## Check Numpy Version

“The programming language Python has become the most renowned programming language in the world in the previous years, and now we can see it used everywhere in almost every field. This programming language is now recognized as a general-purpose language that can be used in web development, automation, or autonomous systems, for statistical data analysis (data science), software testing, and for every general task to get done. When we call python a general-purpose language, then we mean that we may use this language in a variety of tasks, and it offers to create various programs and is not just limited to the specific function or the programs. The script of python is easy to understand, and it’s beginner-friendly, too, with so much versatility in it, which makes this language stand out from all other programming languages.

Python provides various library packages, and one of the most important libraries is “Numpy”. This library needs no introduction when it comes to matrices and the nd-arrays because if we have ever worked on the array or the matrices in the Python script, then we must be familiar with this library as no array or the faster array operations are possible without this library since Numpy is used to work with and for the nd-arrays. This library also provides functions for working with linear algebraic operations, mathematical computations, arithmetic operations, and the Fourier transform.

This library is mostly used in machine learning and data science since these fields deal with the nd-arrays, and the nd-array is the array object in the numpy, so to support working with the arrays, numpy provides a lot of functions. In comparison to the python lists (that are used as arrays), the numpy provides 50 times faster array object. The Numpy check version is used to know about the version of the numpy being installed in the compilers.”

## Procedure

Numpy was introduced in the year 2005 by “Travis Oliphant” as an open-source project, and anyone can access and use it free of cost. The abbreviation for the Numpy is the “numerical python”. In this article, we will demonstrate how we can check for the version of the python library “numpy”. This check can be done following the different procedures and commands, and we will mention a few of those methods in the article.

## Methods

To check for the numpy version, we will be exploring and explaining the following four methods:

- Using the dot operators
- Numpy version check with underlines “_”
- Check the version through the command window
- Numpy version using pip command

Before actually moving to check the numpy version using the above-mentioned methods, we will first be required to know if we have installed the “Numpy” library or not. To confirm the installation of the numpy library in the python interpreter. Open the python interpreter and then go to the command window in your system and type the command “Python”, and hit enter. The command window should display the output as the following figure

The command window should return the python version and relevant information regarding the setup. The most important thing to observe in the output is “>>>”, which says that the interactive python session is started and then in this interactive session, we will check for the python installation by following the command:

Press enter. If the numpy is installed, then no error message will appear on the screen, but if there is an error message, as mentioned in the figure below, then this means that either the numpy is not installed properly or it was not even installed. The error message would be in the following way:

In case of no error, we would then proceed to the following methods to check the version of the numpy using both the python compiler and the command window.

## Check the Version Through the Command Window

After confirming the installation for the numpy in the command window, write the following commands to know the version of numpy

The code will return the version for this numpy as shown in the figure given below:

## Using the Dot Operators

Open the python interpreter, first import the “numpy” as the prefix “np” and then use this prefix and check the version for the numpy using the “np. version. version” and press enter. The command for this check is as follows:

$ np.version.version

After writing the above two commands, the compiler should return the numpy version for the installed numpy in the setup. The results for these commands are shown in the following snippet:

## Numpy Version Check With Underlines “_”

Another method to check for the version of the numpy is to use the underlines with the start and the end of the name with the “np” prefix. So, for this, first, we will import the numpy module from the numpy library with the name “np”, and then we will use this “np” and will call for the numpy version as “np”_version_. The commands used for this method are:

$ np.__version__

The version of the numpy will be displayed then as follows:

**Numpy Version Using Pip Command**

Another method to show the numpy version for the installed numpy package is to use the pip commands. So, to use this pip command, we would have to move to the command window and type the following command, and press enter:

The pip offers several other commands to check the versions for the packages, but here we will only stick to the pip show command.

## Conclusion

The methods to check for the version of the numpy have been explained in this article. We have discussed four different ways to show the version for the numpy. From these four methods, two of the methods explain how to know the numpy version through the command window, and rest two explain the method to check for version through a python interpreter using various commands.

Source: linuxhint.com