Open In App

How to check NumPy version installed?

Last Updated : 25 Sep, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we are going to learn how we can find out which version of NumPy your Python code uses. The version of any project keeps on changing with time as the project gets updated, new features keep being added, and old bugs are removed. Hence, a lot of work keeps on happening on projects especially one like NumPy which is a very popular Python library.

Check the version of NumPy

You can find out the version of NumPy using the following methods:

Using <Module.__version>

To find out the version of NumPy you are using, just import the module (if not already imported) and then print out “numpy.__version__“.

Syntax: print(np.__version__)

Example

Python3




import numpy as np
 
print("My numpy version is: ", np.__version__)


Output

My numpy version is:  1.23.2

Using pip show to check version of Numpy

You can also the run the “pip show” command in your terminal to find out the details of the package you are using which also mentions the version inside it.

Syntax: pip show <package_name>

Example

pip show numpy

Output

numpy_pip_show

Using pip list command

You can run the “pip list” command in your terminal which mentions all the installed packages along with their versions written aside them.

Syntax: pip list

Output

numpy_pip_list

Using importlib.metadata

You can import the “importlib.metadata” package inside your python code and find out information about metadata of various python packages you have installed.

Syntax

import importlib.metadata as metadata
print(metadata.version(package_name))

Example

Python3




import importlib.metadata as metadata
 
np_version = metadata.version("numpy")
 
print("My numpy version is: ", np_version)


Output

My numpy version is:  1.23.2


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads