Python numpy version check

How to Check the NumPy Version

There are multiple ways to check the NumPy version; however, the easiest and PEP8 standard practice is to import numpy and use the numpy.__version__ attribute to get the exact version details.

This guide will look at various ways to get the NumPy version. Let us look at each of the approaches using code examples.

Check the NumPy version using __version__ attribute

The easiest and Pythonic way to get the NumPy version is by using the __version__ attribute. This is the standard way to check the version of any standard Python libraries.

import numpy print(numpy.__version__)

Get the Detailed Version of NumPy

If you need detailed information on the NumPy version, then we can use np.version . The version.py file gets generated using setup.py when we install the NumPy package, and it holds the version information such as version, short_version, full_version, etc.

import numpy as np print(np.version.version) print(np.version.short_version) print(np.version.full_version) print(np.version.git_revision) print(np.version.release)
1.21.6 1.21.6 1.21.6 ef0ec786fd4c7622ad2fa0e54d3881f3b9bbd792 True
Note: The version, short_version, full_version will have the same value. If it's not a release version then the git_revision is added to the version and full_version.

Get the NumPy version using pip3

We can use the pip3 command to get the NumPy version. There are multiple ways to get the NumPy version using the pip command.

Читайте также:  Php replace null in array

The pip3 list command will list all the packages installed in your system or virtual environment.

numpy 1.21.6 openpyxl 3.0.10 pandas 1.1.5

Instead of listing all the packages, you can find the NumPy package by using the command

>> pip3 list | FINDSTR numpy numpy 1.21.6
$ pip list | grep numpy numpy 1.21.6

The second approach is to use the pip3 show command. It will provide complete information(version, author, installation path, license, etc.) on NumPy if installed on your machine or virtual environment.

Name: numpy Version: 1.21.6 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: License: BSD Location: c:\users\m1014107\appdata\local\programs\python\python37\lib\site-packages Requires: Required-by: pandas

The third approach is to use pip3 freeze to get any Python package version without opening the Python shell.

>> pip freeze | FINDSTR 'numpy' numpy==1.21.6
$ pip freeze | grep 'numpy' numpy==1.21.6

Verify the NumPy version on Anaconda Distribution.

We can get the NumPy version in the Anaconda distribution using the conda command. Open the Anaconda prompt and type the below command.

# Name Version Build Channel numpy 1.21.6 py38h34a8a5c_0 numpy-base 1.21.6 py38haf7ebc8_0 numpydoc 1.1.6 pyhd3eb1b0_1
numpy 1.21.6 py38h7241aed_0 numpy-base 1.21.6 py38h6575580_1 numpydoc 1.1.6 py_0

The other alternate way is to use the command line and print the NumPy version, as shown below.

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

Conclusion

There are multiple ways to check the NumPy version; the Pythonic and PEP8 standard ways are to use the numpy.__version__ attribute. Alternatively, we can also use the pip3 command to get the Python version.

Источник

How to Check if NumPy is Installed and Find Your NumPy Version

The 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.

Check if 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 numpy version.

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. >>>

The >>> 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 "", line 1, in ModuleNotFoundError: No module named 'numpy' >>>

2. With pip show

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’.

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
WARNING: Package(s) not found: numpy

If you have both Python2 and Python3 installed you will need to replace python with python3 when referencing the Python3 installation.

3. With conda list

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’.

(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
(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.

1. With numpy

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'

2. With pip show

Above we used pip show to determine if numpy was installed. You may have noticed, that the result also showed the package version. Type python -m pip show and press ‘Enter’. The result will show the package version and other information about the package.

3. With conda list

We also used conda list above to check the numpy installation. Once again, you may have noticed this command also gave information about the numpy version. 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.

Conclusion

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.

Whether you’re looking to take your GIS skills to the next level, or just getting started with GIS, we have a course for you! We’re constantly creating and curating more courses to help you improve your geospatial skills.

QGIS for Beginners

Remote Sensing with QGIS

QGIS Python Scripting with PyQGIS

All of our courses are taught by industry professionals and include step-by-step video instruction so you don’t get lost in YouTube videos and blog posts, downloadable data so you can reproduce everything the instructor does, and code you can copy so you can avoid repetitive typing

My Recommended Equipment Computer: Dell XPS Mouse: Logitech M557 Bluetooth Mouse 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.

Konrad Hafen Konrad has a Master’s Degree in Ecology and a Doctorate Degree in Water Resources and has been performing geospatial analysis and writing code (in multiple programming languages) for over a decade. He writes code to develop models and analysis workflows to predict and evaluate changes to landscapes and water resources. He has published multiple articles in prominent peer-reviewed, scientific journals. Konrad’s code and workflow contribute to operational products that inform water and ecosystem management.

Latest Tutorials

With QGIS reprojections can be calculated with the export data tool, the reproject layer tool, and GDAL Warp. Reprojecting layers (i.e., converting them to a different coordinate reference system, or.

In cartography and GIS, it is to display two different products side by side to make comparisons. This is a powerful and often necessary feature of any serious GIS software. QGIS makes it possible to.

About Us

We believe data processing and analytics routines should be repeatable without purchasing expensive software licenses. This is possible with open-source programs and programming languages. Our goal is to help you learn open-source software and programming languages for GIS and data science. We do this with free tutorials and paid courses. More About Us

Источник

Check NumPy version: np.version

This article explains how to check the NumPy version used in Python ( .py ) or Jupyter Notebook ( .ipynb ).

Refer to the following article to learn how to check the version of NumPy installed in your environment using the pip command.

Check NumPy version: the __version__ attribute

Like many other packages, you can get the NumPy version using the __version__ attribute.

import numpy as np print(np.__version__) # 1.24.3 

Get detailed NumPy version information: np.version

Detailed information about the NumPy version, such as the Git revision and whether it’s a release version, can be obtained from the np.version module.

print(np.version) #  print(np.version.version) # 1.24.3 print(np.version.short_version) # 1.24.3 print(np.version.full_version) # 1.24.3 print(np.version.git_revision) # 14bb214bca49b167abc375fa873466a811e62102 print(np.version.release) # True 

In the above example, version , short_version , and full_version all have the same value. However, if it is not a release version, additional information is added to version and full_version .

  • NumPy: Count the number of elements satisfying the condition
  • NumPy: Determine if ndarray is view or copy and if it shares memory
  • NumPy: Insert elements, rows, and columns into an array with np.insert()
  • Image processing with Python, NumPy
  • numpy.arange(), linspace(): Generate ndarray with evenly spaced values
  • Flatten a NumPy array with ravel() and flatten()
  • Alpha blending and masking of images with Python, OpenCV, NumPy
  • Convert numpy.ndarray and list to each other
  • numpy.delete(): Delete rows and columns of ndarray
  • List of NumPy articles
  • NumPy: np.sign(), np.signbit(), np.copysign()
  • NumPy: Calculate the sum, mean, max, min of ndarray containing np.nan
  • Generate gradient image with Python, NumPy
  • OpenCV, NumPy: Rotate and flip image
  • NumPy: Arrange ndarray in tiles with np.tile()

Источник

Оцените статью