w3resource

NumPy: Print the NumPy version in your system


Print NumPy Version

Write a NumPy program to print the NumPy version on your system.

Sample Solution:-

Python Code:

# Importing the NumPy library with an alias 'np'
import numpy as np

# Printing the version of NumPy installed
print(np.__version__)

Sample Output:

1.12.0

Explanation:

In the above code -

print(np.__version__): Accesses the __version__ attribute of the NumPy library, which holds a string representing the version number of the currently installed NumPy package. This line prints the version number.

NumPy version:

class numpy.lib.NumpyVersion(vstring): Parse and compare numpy version strings.

New in version 1.9.0.
Parameters vstring : str
NumPy version string (np.__version__).

Python-Numpy Code Editor: