w3resource

NumPy: Get the numpy version and show numpy build configuration

NumPy: Basic Exercise-1 with Solution

Write a Numpy program to get the Numpy version and show the Numpy build configuration.

This problem involves using NumPy to retrieve information about the library itself. The task is to write a program that displays the installed NumPy version and shows the build configuration details. This information is useful for debugging, ensuring compatibility, and understanding how NumPy was compiled and set up on the system.

Sample Solution :

Python Code :

# Importing the NumPy library with an alias 'np'
import numpy as np

# Printing the version of NumPy installed
print(np.__version__)

# Printing the configuration details of NumPy
print(np.show_config())

Output:

lapack_opt_info:
    library_dirs = ['C:\\projects\\numpy-wheels\\numpy\\build\\openblas']
    define_macros = [('HAVE_CBLAS', None)]
    libraries = ['openblas']
    language = f77
blis_info:
  NOT AVAILABLE
blas_opt_info:
    library_dirs = ['C:\\projects\\numpy-wheels\\numpy\\build\\openblas']
    define_macros = [('HAVE_CBLAS', None)]
    libraries = ['openblas']
    language = f77
openblas_lapack_info:
    library_dirs = ['C:\\projects\\numpy-wheels\\numpy\\build\\openblas']
    define_macros = [('HAVE_CBLAS', None)]
    libraries = ['openblas']
    language = f77
openblas_info:
    library_dirs = ['C:\\projects\\numpy-wheels\\numpy\\build\\openblas']
    define_macros = [('HAVE_CBLAS', None)]
    libraries = ['openblas']
    language = f77
blas_mkl_info:
  NOT AVAILABLE
lapack_mkl_info:
  NOT AVAILABLE
None                         

Explanation:

In the above code –

print(np.__version__): This line prints the version number of the NumPy library being used. The __version__ attribute is a string that contains the library's version information.

print(np.show_config()): This line prints the configuration information of the NumPy library.

Python-Numpy Code Editor:

Previous: NumPy Exercises Home.
Next: NumPy program to get help on the add function.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/python-exercises/numpy/basic/numpy-basic-exercise-1.php