numpy Python module is widely used for many different analyses and as a dependency for many other Python packages. In many instances, it is necessary to determine if
numpy is installed and which
numpy version is installed. This article will show you multiple ways to determine your
numpy version and installation status.
numpy is installed
Here are three ways to check if
numpy, or any other Python package, is installed. Note, that some of these methods also tell you the
1. In an interactive Python session
The first way to check if
numpy is installed is to start an interactive Python session. You do this by opening up a command prompt/terminal, typing
python, and pressing ‘Enter’.
You should now see something that shows information about the Python distribution you are using, followed by three greater-than signs. Like this:
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information. >>>
>>> indicates that the code you type will be executed by the Python interpreter.
To check if
numpy is installed just try to import it with the following line of code. Then press ‘Enter’.
If there is no error message then it means
numpy is installed. If you get an error message like the one below it means that
numpy is not installed or that it was improperly installed.
>>> import numpy Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'numpy' >>>
To exit the interactive Python session simply type
quit() and press enter.
You can also check your
numpy installation with
pip, a Python package manager/installer. To do so, make sure your are not in an interactive Python session. Then type the following command in the command prompt and press ‘Enter’.
python -m pip show numpy
numpy is installed you will see a message like this:
Name: numpy Version: 1.20.1 Summary: NumPy is the fundamental package for array computing with Python. Home-page: https://www.numpy.org Author: Travis E. Oliphant et al. Author-email: None License: BSD Location: c:\users\konrad\anaconda3\lib\site-packages Requires: Required-by: tifffile, tables, statsmodels, seaborn, scipy, scikit-learn, scikit-image, PyWavelets, pyerfa, patsy, pandas, numexpr, numba, mkl-random, mkl-fft, matplotlib, imageio, imagecodecs, h5py, Bottleneck, bokeh, bkcharts, astropy
numpy is not installed you will see a message like this.
WARNING: Package(s) not found: numpy
If you have both Python2 and Python3 installed you will need to replace
python3 when referencing the Python3 installation.
If you are using an Anaconda Python distribution you can check for a numpy installation using the
conda command. First, open up the Anaconda Prompt. They type the following and press ‘Enter’.
conda list numpy
numpy is installed you will get a message like this.
(base) C:\Users\Konrad>conda list numpy # packages in environment at C:\Users\Konrad\anaconda3: # # Name Version Build Channel numpy 1.20.1 py38h34a8a5c_0 numpy-base 1.20.1 py38haf7ebc8_0 numpydoc 1.1.0 pyhd3eb1b0_1
numpy is not installed you will see an empty result, like this.
(base) C:\Users\Konrad>conda list numpy # packages in environment at C:\Users\Konrad\anaconda3: # # Name Version Build Channel (base) C:\Users\Konrad>
Check Your `numpy version
Once you’ve determined that
numpy is installed you can check your
numpy version. I will show you three ways to check your
numpy version. Note that two of them are the same as shown above.
You can check your
numpy version by opening an interactive Python session, importing
numpy and use
numpy.__version__ to check the version, as shown below.
>>> import numpy >>> numpy.__version__ '1.20.1'
Above we used
pip show to determine if
numpy was installed. You may have noticed, that the result also showed the package version.
python -m pip show and press ‘Enter’. The result will show the package version and other information about the package.
We also used
conda list above to check the
numpy installation. Once again, you may have noticed this command also gave information about the
Make sure you are using the Anaconda prompt, as the
conda command only works in an Anaconda environment, and type
conda list numpy. The result will show the version of
numpy and associated packages.
That’s it. Now you know how to check your
numpy version and installation status in a number of ways. If you would like a visual walk-through, check out the video below.
My Recommended Equipment
Computer: Dell XPS
External Hard Drive: Seagate Portable 2TB
This article contains affiliate links. When you click on links in this article Open Source Options may make a commission on any sales. This does not have any impact on the price you pay for products.