-2

I am following instructions to make a very simple neural network program, and I keep getting an error from my line to import NumPy.

import numpy as np

I always get the following error:

ModuleNotFoundError: No module named 'numpy'

When I use the Mac console and type import numpy, it works fine.

When I am typing the import statement in PyCharm and type it slowly to see what intellisense suggests, it suggests "numbers" or "enum", but NumPy is not there.

When I use the Mac console, I can write import numpy without any problems.

I checked the class-path and it appears to include the Anaconda folders, which is where NumPy is.

  • Python version: 3.7.3
  • NumPy version: 1.16.4
  • macOS v10.14 (Mojave)
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • Related (2019): *[Mac OS X: "ModuleNotFoundError: No module named 'numpy'"](https://stackoverflow.com/questions/56252299/mac-os-x-modulenotfounderror-no-module-named-numpy)* – Peter Mortensen Aug 22 '22 at 15:17

3 Answers3

1

If you haven't installed NumPy like,

pip install NumPy

or

pip3 install NumPy

that will most likely be the answer.

If you have I would suggest reinstalling the NumPy package:

pip reinstall numpy

or

pip3 reinstall numpy

Another thing is just try to look at the NumPy page, and search for anything else that might help you!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Brody Critchlow
  • 45
  • 3
  • 21
1

Python looks for modules in every directory listed in sys.path. The Python binary (and module paths) are almost certainly different for PyCharm and the system installed (Terminal) environments.

You will have to install NumPy within PyCharm. Alternately, you can use sys.path.append(0,'/path/to/numpy') or (in Bash) PYTHONPATH=$PYTHONPATH:/path/to/numpy to temporarily extend the sys.path array to point to another distribution of NumPy on your system.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Daniel R. Livingston
  • 1,227
  • 14
  • 36
-2

I tried uninstalling and reinstalling it, but there wasn't any difference.

Atom doesn't have any problem with the import statement. It's only PyCharm, so I will stick to Atom.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131