Open In App

How to Fix: No module named NumPy

Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will discuss how to fix the No module named numpy using Python.

Numpy is a module used for array processing. The error “No module named numpy ” will occur when there is no NumPy library in your environment i.e. the NumPy module is either not installed or some part of the installation is incomplete due to some interruption. We will discuss how to overcome this error.

In Python, we will use pip function to install any module

Syntax:

pip install module_name

Example: How to install NumPy

pip install numpy

Output:

Collecting numpy

  Downloading numpy-3.2.0.tar.gz (281.3 MB)

     |████████████████████████████████| 281.3 MB 9.7 kB/s 

Collecting py4j==0.10.9.2

  Downloading py4j-0.10.9.2-py2.py3-none-any.whl (198 kB)

     |████████████████████████████████| 198 kB 52.8 MB/s 

Building wheels for collected packages: numpy

  Building wheel for numpy (setup.py) … done

  Created wheel for numpy: filename=numpy-3.2.0-py2.py3-none-any.whl size=281805912 sha256=c6c9edb963f9a25f31d11d88374ce3be6b3c73ac73ac467ef40b51b5f4eca737

  Stored in directory: /root/.cache/pip/wheels/0b/de/d2/9be5d59d7331c6c2a7c1b6d1a4f463ce107332b1ecd4e80718

Successfully built numpy

Installing collected packages: py4j, numpy

Successfully installed py4j-0.10.9.2 numpy-3.2.0

We can verify by again typing same command then output will be:

Output:

Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (1.1.5)

To get the numpy description like the current version in our environment we can use show command  

Example: To get NumPy description 

pip show numpy

Output:

Name: numpy

Version: 1.19.5

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: /usr/local/lib/python3.7/dist-packages

Requires: 

Required-by: yellowbrick, xgboost, xarray, wordcloud, torchvision, torchtext, tifffile, thinc, Theano-PyMC, tensorflow, tensorflow-probability, tensorflow-hub, tensorflow-datasets, tensorboard, tables, statsmodels, spacy, sklearn-pandas, seaborn, scs, scipy, scikit-learn, scikit-image, resampy, qdldl, PyWavelets, python-louvain, pystan, pysndfile, pymc3, pyerfa, pyemd, pyarrow, plotnine, patsy, pandas, osqp, opt-einsum, opencv-python, opencv-contrib-python, numexpr, numba, nibabel, netCDF4, moviepy, mlxtend, mizani, missingno, matplotlib, matplotlib-venn, lightgbm, librosa, Keras-Preprocessing, kapre, jpeg4py, jaxlib, jax, imgaug, imbalanced-learn, imageio, hyperopt, holoviews, h5py, gym, gensim, folium, fix-yahoo-finance, fbprophet, fastprogress, fastdtw, fastai, fa2, ecos, daft, cvxpy, cufflinks, cmdstanpy, cftime, Bottleneck, bokeh, blis, autograd, atari-py, astropy, arviz, altair, albumentations

The installation remains same for all other operating systems and software just the platform changes. If our installation is successful any NumPy code will work fine 

Example: Program to create a NumPy array and display

Python3




#import module
import numpy
  
# create an numpy array with 5 elements
data = numpy.array([1, 2, 3, 4, 5])
  
# display
data


Output:

array([1, 2, 3, 4, 5])

Last Updated : 19 Dec, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads