close

[Solved] ModuleNotFoundError: No module named ‘numpy’

I am trying to use numpy But I am facing the following error: ModuleNotFoundError: No module named ‘numpy’. In this Exerror article, We are going to learn about How to reproduce this error and we will discuss All Possible Solutions Let’s Get Start With This Article.

How ModuleNotFoundError: No module named ‘numpy’ Error Occurs?

I am trying to use numpy But I am facing the following error.

ModuleNotFoundError: No module named 'numpy'

So here I am writing all the possible solutions that I have tried to resolve this error.

How To Solve ModuleNotFoundError: No module named ‘numpy’ Error?

  1. How To Solve ModuleNotFoundError: No module named ‘numpy’ Error?

    To Solve ModuleNotFoundError: No module named ‘numpy’ Error If You are using a Virtual Environment then Follow these steps. First of all, create a virtual env by running this command: python3 -m venv venv Then activate it by running: source venv/bin/activate Then install numpy in your virtual environment: pip install numpy I Hope, Your error may be solved now.

  2. ModuleNotFoundError: No module named ‘numpy’

    Usually this error is occurs whenever we are trying to use numpy without installing it To Solve ModuleNotFoundError: No module named ‘numpy’ Error You just need to install numpy by running pip install numpy and your error will be solved. If You are using Python 2 Then run This command: pip install numpy And If You are using Python 3 then run this command: pip3 install numpy If You don’t have the pip Path Variable set then run this command: python3 -m pip install numpy If You are using anaconda then you need to run this command: conda install -c anaconda numpy Now, Your error will be solved. Thank you.

Solution 1: Install numpy

Usually this error is occurs whenever we are trying to use numpy without installing it To Solve ModuleNotFoundError: No module named ‘numpy’ Error You just need to install numpy by running pip install numpy and your error will be solved.

If You are using Python 2 Then run This command.

pip install numpy

And If You are using Python 3 then run this command.

pip3 install numpy

If You don’t have the pip Path Variable set then run this command.

# For Python2
python -m pip install numpy

# For Python3
python3 -m pip install numpy

If You are using anaconda then you need to run this command.

conda install -c anaconda numpy

Now, Your error will be solved. Thank you.

Solution 2: For virtual environment

If You are using a Virtual Environment then Follow these steps. First of all, create a virtual env by running this command.

python3 -m venv venv

Then activate it by running,

# For linux macos
source venv/bin/activate

#For Windows
venv\Scripts\activate.bat

Then install numpy in your virtual environment.

pip install numpy

I Hope, Your error may be solved now.

Solution 3: Reinstall numpy

First of all, check If you have NumPy installed in your system You need to run this command in your terminal.

pip3 show numpy

# OR 

python3 -m pip show numpy

Now, the Above command will give you the version that is installed in your system and If you don’t have installed NumPy then Just install But before we need to uninstall NumPy by running this.

pip3 uninstall numpy

# OR

python3 -m pip uninstall numpy

And now, Reinstall NumPy by running this command.

pip3 install numpy

# OR

python3 -m pip install numpy

Now, Your error will be solved. Thank You.

Conclusion

It’s all About this error. I hope We Have solved Your error. Comment below Your thoughts and your queries. Also, Comment below on which solution worked for you.

Also, Read

Leave a Comment