Wednesday, July 3, 2024
HomeLanguagesPythonHow to check NumPy version installed?

How to check NumPy version installed?

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

Nango Kalahttps://www.kala.co.za
Experienced Support Engineer with a demonstrated history of working in the information technology and services industry. Skilled in Microsoft Excel, Customer Service, Microsoft Word, Technical Support, and Microsoft Office. Strong information technology professional with a Microsoft Certificate Solutions Expert (Privet Cloud) focused in Information Technology from Broadband Collage Of Technology.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments