How do I fix the "ModuleNotFoundError: No module named 'numpy'" error on Windows, even after installing it?

I’m running Python 3 on a Windows 7 64-bit system (only one version installed), and I installed NumPy as instructed in various tutorials. The installation completed without errors.

However, when I try to run:

import numpy

I get the following error: modulenotfounderror: no module named ‘numpy’

Even though pip showed that NumPy was installed successfully. How can I resolve this modulenotfounderror: no module named ‘numpy’ issue? Is it possible that NumPy was installed in a different environment or path than the one my script is using? Would appreciate help from anyone who’s faced this on Windows!

hello @mridukant, this error usually means NumPy was installed in a different Python environment than the one your script is using. Even if the install looked successful, your script might be running with a different Python version or path. To fix it, make sure you’re installing NumPy using the same Python that’s running your script. Also, double-check if there are multiple Python versions installed on your system. Matching the right environment usually solves the issue. Hope that helps.

1 Like

Been there plenty of times in my years working with Python on Windows! The “modulenotfounderror: no module named ‘numpy’” often comes down to having multiple Python installations lurking on your system. Even if pip swears NumPy is installed, it might’ve landed in a different Python environment than the one you’re actually running.

Quick sanity check: open the same shell you’re using for your script and run:


where python
where pip

If they point to different folders—say, one in C:\Python39 and the other under AppData or a virtualenv—that’s your culprit. To be absolutely sure you’re installing into the right Python, try this instead:

python -m pip install numpy

That way, pip uses the exact Python interpreter you want.

Couldn’t agree more with @miro.vasil, I’ve wrangled the “modulenotfounderror: no module named ‘numpy’” a bunch myself. One extra thing to check: Windows PATH issues. It’s especially messy if you installed Python manually and the PATH didn’t update.

Pop open a command prompt and type:

python

If Python doesn’t launch or it’s the wrong version, that’s a sign your PATH needs fixing.

Also, find out where pip actually installed NumPy:

pip show numpy

Look at the “Location” path it prints. Then check where Python’s looking for packages:

python -c "import sys; print(sys.path)

If NumPy’s install path isn’t listed anywhere there, that’s why you’re seeing “modulenotfounderror: no module named ‘numpy’.” Basically, Python can’t find it.