Check NumPy version: np.version
This article explains how to check the NumPy version used in Python (.py
) or Jupyter Notebook (.ipynb
).
Contents
Refer to the following article to learn how to check the version of NumPy installed in your environment using the pip
command.
Check NumPy version: the __version__
attribute
Like many other packages, you can get the NumPy version using the __version__
attribute.
import numpy as np
print(np.__version__)
# 1.24.3
source: numpy_version.py
Get detailed NumPy version information: np.version
Detailed information about the NumPy version, such as the Git revision and whether it's a release version, can be obtained from the np.version
module.
print(np.version)
# <module 'numpy.version' from '/opt/homebrew/lib/python3.11/site-packages/numpy/version.py'>
print(np.version.version)
# 1.24.3
print(np.version.short_version)
# 1.24.3
print(np.version.full_version)
# 1.24.3
print(np.version.git_revision)
# 14bb214bca49b167abc375fa873466a811e62102
print(np.version.release)
# True
source: numpy_version.py
In the above example, version
, short_version
, and full_version
all have the same value. However, if it is not a release version, additional information is added to version
and full_version
.