note.nkmk.me

Check NumPy version: np.version

Posted: 2019-09-20 / Tags: Python, NumPy

There are following ways to check the version of NumPy used in the script.

  • Get version number: __version__ attribute
  • Get detailed information such as Git revision: np.version

See the following post for how to check the installed NumPy version with pip command.

Sponsored Link

Get version number: __version__ attribute

Like many other packages, you can get the version number of NumPy with the __version__ attribute.

import numpy as np

print(np.__version__)
# 1.14.1

Get detailed information such as Git revision: np.version

version.py file is generated from setup.py when NumPy is installed, you can get the following values.

print(np.version.version)
# 1.14.1

print(np.version.short_version)
# 1.14.1

print(np.version.full_version)
# 1.14.1

print(np.version.git_revision)
# 7dcee7a469ad1bbfef1cd8980dc18bf5869c5391

print(np.version.release)
# True

In the above example, version, short_version, and full_version all have the same value, but if it is not the release version, git_revision is added to version and full_version.

See the link below for the source.

Sponsored Link
Share

Related Categories

Related Posts