How can I check which version of NumPy I'm using?
17 Answers
import numpy
numpy.version.version
4 Comments
import numpy ; numpy.version.version . The lack of import numpy through me, an obvious newbie.__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 <package>.__version__ as Dominic Rodger's answer recommends Parse the version (and create your own version strings) as recommended in PEP 386 / PEP 440.numpy.version.version is typed, and numpy.__version__ is not (could be an oversight).import numpy
print(numpy.__version__)
4 Comments
print(np.__version__)From the command line, you can simply issue:
python -c "import numpy; print(numpy.version.version)"
Or:
python -c "import numpy; print(numpy.__version__)"
1 Comment
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)
....
1 Comment
pip freeze if in a virtual environment?We can use pip freeze to get any Python package version without opening the Python shell.
pip freeze | grep 'numpy'
1 Comment
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)
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1 Comment
conda list numpyYou 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
1 Comment
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.For Python 3.X print syntax:
python -c "import numpy; print (numpy.version.version)"
Or
python -c "import numpy; print(numpy.__version__)"
1 Comment
print(numpy.__version__), not print numpy.__version__