369

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

Adriaan
  • 17,741
  • 7
  • 42
  • 75
larus
  • 4,359
  • 4
  • 21
  • 13
  • 1
    probable you just need to install specific version of [numpy](https://stackoverflow.com/questions/1520234/how-do-i-check-which-version-of-numpy-im-using/53898417#53898417) – prosti Dec 22 '18 at 18:49

17 Answers17

475
import numpy
numpy.version.version
David Stansby
  • 1,703
  • 1
  • 15
  • 18
SilentGhost
  • 307,395
  • 66
  • 306
  • 293
  • 74
    This is not the public API, numpy.__version__ is. – David Cournapeau Nov 22 '11 at 10:10
  • 13
    Actually `import numpy ; numpy.version.version` . The lack of `import numpy` through me, an obvious newbie. – mmorris Apr 20 '12 at 01:20
  • 16
    Since the use of `__version__` in recommended in PEP8 and most packages support `__version__` vs the non standard `version.version` I think that this answer should be treated more as a curiosity than an accepted method. Use `numpy.__version__` or `.__version__` as [Dominic Rodger's answer recommends](http://stackoverflow.com/a/1520264/298607) Parse the version (and create your own version strings) as recommended in PEP 386 / PEP 440. – dawg Apr 02 '14 at 16:09
  • Actually, in NumPy 1.20, `numpy.version.version` is typed, and `numpy.__version__` is not (could be an oversight). – Henry Schreiner Jan 31 '21 at 16:43
284
import numpy
print(numpy.__version__)
Mateen Ulhaq
  • 24,552
  • 19
  • 101
  • 135
Dominic Rodger
  • 97,747
  • 36
  • 197
  • 212
79

From the command line, you can simply issue:

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

Or:

python -c "import numpy; print(numpy.__version__)"
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
meduz
  • 3,903
  • 1
  • 28
  • 40
  • 1
    This is actually very nice as it allows you to check the version of numpy even if you have two different versions running on two different versions of python. py -2 -c "import numpy; print(numpy.version.version)" py -3 -c "import numpy; print(numpy.version.version)" – JSWilson Aug 18 '20 at 20:57
37

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)
....
Lavanya Shukla
  • 371
  • 3
  • 2
19

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

import numpy
numpy.show_config()
David C
  • 7,204
  • 5
  • 46
  • 65
13

You can try this:

pip show numpy

SDt
  • 432
  • 1
  • 4
  • 10
11

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

pip freeze | grep 'numpy'
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ajay Gupta
  • 3,192
  • 1
  • 22
  • 30
8

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)
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Community
  • 1
  • 1
kmario23
  • 57,311
  • 13
  • 161
  • 150
7

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.

Sajidur Rahman
  • 2,764
  • 1
  • 27
  • 26
5

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
Rogelio Prieto
  • 359
  • 3
  • 10
  • Just a slight caution that it's possible that you may have python and python 3 both installed with numpy. Then when doing the `pip list | grep numpy` method it will show one of the two (typically the python 3's numpy version). When you run the `shownumpy.py` program on both python and python 3, they will show you exactly what version is on each respective python environment. – Caleb Feb 22 '19 at 20:37
4

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
Tanner Dolby
  • 4,253
  • 3
  • 10
  • 21
3

For Python 3.X print syntax:

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

Or

python -c "import numpy; print(numpy.__version__)"
Guillaume Jacquenot
  • 11,217
  • 6
  • 43
  • 49
  • 1
    Exact duplicate of the answer of @meduz . For python 3, it is `print(numpy.__version__)`, not `print numpy.__version__` – francis Mar 23 '16 at 15:02
3
import numpy
print numpy.__version__
2

In a Python shell:

>>> help()
help> numpy
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
LMB
  • 384
  • 2
  • 6
  • 18
2

For Windows

pip list | FINDSTR numpy

For Linux

pip list | grep numpy
Arihant Jain
  • 817
  • 5
  • 17
1

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)
Ginés Hidalgo
  • 717
  • 9
  • 20
0

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.

prosti
  • 42,291
  • 14
  • 186
  • 151