[python] How do I check which version of NumPy I'm using?

How can I check which version of NumPy I'm using?

(FYI this question has been edited because both the question and answer are not platform specific.)

This question is related to python numpy version

The answer is


We can use pip freeze to get any Python package version without opening the Python shell.

pip freeze | grep 'numpy'

Just a slight solution change for checking the version of numpy with Python,

import numpy as np 
print("Numpy Version:",np.__version__)

Or,

import numpy as np
print("Numpy Version:",np.version.version)

My projects in PyCharm are currently running version

1.17.4

>> import numpy
>> print numpy.__version__

Run:

pip list

Should generate a list of packages. Scroll through to numpy.

...
nbpresent (3.0.2)
networkx (1.11)
nltk (3.2.2)
nose (1.3.7)
notebook (5.0.0)
numba (0.32.0+0.g139e4c6.dirty)
numexpr (2.6.2)
numpy (1.11.3) <--
numpydoc (0.6.0)
odo (0.5.0)
openpyxl (2.4.1)
pandas (0.20.1)
pandocfilters (1.4.1)
....

In a Python shell:

>>> help()
help> numpy

From the command line, you can simply issue:

python -c "import numpy; print(numpy.version.version)"

Or:

python -c "import numpy; print(numpy.__version__)"

It is good to know the version of numpy you run, but strictly speaking if you just need to have specific version on your system you can write like this:

pip install numpy==1.14.3 and this will install the version you need and uninstall other versions of numpy.


Pure Python line that can be executed from the terminal (both 2.X and 3.X versions):

python -c "import numpy; print(numpy.version.version)"

If you are already inside Python, then:

import numpy
print(numpy.version.version)

Simply

pip show numpy

and for pip3

pip3 show numpy

Works on both windows and linux. Should work on mac too if you are using pip.


You can also check if your version is using MKL with:

import numpy
numpy.show_config()

If you're using NumPy from the Anaconda distribution, then you can just do:

$ conda list | grep numpy
numpy     1.11.3     py35_0

This gives the Python version as well.


If you want something fancy, then use numexpr

It gives lot of information as you can see below:

In [692]: import numexpr

In [693]: numexpr.print_versions()
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Numexpr version:   2.6.2
NumPy version:     1.13.3
Python version:    3.6.3 |Anaconda custom (64-bit)|
                   (default, Oct 13 2017, 12:02:49)
[GCC 7.2.0]
Platform:          linux-x86_64
AMD/Intel CPU?     True
VML available?     False
Number of threads used by default: 8 (out of 48 detected cores)
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

For Python 3.X print syntax:

python -c "import numpy; print (numpy.version.version)"

Or

python -c "import numpy; print(numpy.__version__)"

import numpy
print numpy.__version__

You can get numpy version using Terminal or a Python code.

In a Terminal (bash) using Ubuntu:

pip list | grep numpy

In python 3.6.7, this code shows the numpy version:

import numpy
print (numpy.version.version)

If you insert this code in the file shownumpy.py, you can compile it:

python shownumpy.py

or

python3 shownumpy.py

I've got this output:

1.16.1

You can try this:

pip show numpy


Examples related to python

programming a servo thru a barometer Is there a way to view two blocks of code from the same file simultaneously in Sublime Text? python variable NameError Why my regexp for hyphenated words doesn't work? Comparing a variable with a string python not working when redirecting from bash script is it possible to add colors to python output? Get Public URL for File - Google Cloud Storage - App Engine (Python) Real time face detection OpenCV, Python xlrd.biffh.XLRDError: Excel xlsx file; not supported Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation

Examples related to numpy

Unable to allocate array with shape and data type How to fix 'Object arrays cannot be loaded when allow_pickle=False' for imdb.load_data() function? Numpy, multiply array with scalar TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'" Pytorch tensor to numpy array Numpy Resize/Rescale Image what does numpy ndarray shape do? How to round a numpy array? numpy array TypeError: only integer scalar arrays can be converted to a scalar index

Examples related to version

Which TensorFlow and CUDA version combinations are compatible? How can the default node version be set using NVM? Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51 Which ChromeDriver version is compatible with which Chrome Browser version? How to find which version of TensorFlow is installed in my system? How to update Ruby Version 2.0.0 to the latest version in Mac OSX Yosemite? What does 'Unsupported major.minor version 52.0' mean, and how do I fix it? Find nginx version? How to check all versions of python installed on osx and centos How can I specify the required Node.js version in package.json?