1

First bear with me as I am relatively new to coding. I am trying to import numpy to Jupyter (localhost, webbased) using Python 3 and getting an error.

import numpy as np

ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-0aa0b027fcb6> in <module>()
----> 1 import numpy as np

ModuleNotFoundError: No module named 'numpy'

What should I do? Many thanks.

Martin Brisiak
  • 3,872
  • 12
  • 37
  • 51
sammmm
  • 63
  • 1
  • 1
  • 10
  • 1
    Do you have numpy installed on the machine? pip install numpy – Eytan Avisror Dec 19 '17 at 15:16
  • @EytanAvisror Yes I do. Used it earlier but now I am trying to use it on Jupyter's notebook (webbased). Seems like it is failing to understand any import, including pandas which are installed locally. On another hand, when opening pyton 3.6 (32-bit) and writing "pip install numpy" it is saying "invalid syntax" instead of saying it is already installed for some reason. – sammmm Dec 19 '17 at 15:23
  • Anaconda and the entire package are already installed on my device. Used it earlier but now I am trying to use it on Jupyter's notebook (webbased). Seems like it is failing to understand any import, including pandas which are installed locally. On another hand, when opening pyton 3.6 (32-bit) and writing "pip install numpy" it is saying "invalid syntax" instead of saying it is already installed for some reason. Is it possible for the issue to be due to the fact that my webbased is Python 3 while my local Python is 3.6? – sammmm Dec 19 '17 at 15:25
  • `pip` is not a python command, it is a command line utility that you can run from the command line. If you have different versions of Python on your system the numpy et al. packages may be installed for a different version. What happens if you type `import numpy` in the Python prompt? – MB-F Dec 19 '17 at 15:32
  • @kazemakase "No module named 'numpy' " – sammmm Dec 19 '17 at 15:33
  • 1
    Then numpy is not installed in this Python environment. – MB-F Dec 19 '17 at 15:34
  • 1
    @kazemakase Thanks for helping me find this issue. If I open the regular command prompt and click "ipython" or try to import numpy it works. Any idea how I should import it to the python 3 env and the jupyter notebook env? – sammmm Dec 19 '17 at 15:38

2 Answers2

0

Maybe try download Anaconda and using that as your interpreter. Pretty sure that comes preinstalled with Numpy. Or check that you are following the correct way for installing the python 3 version: think this might help: Install numpy on python3.3 - Install pip for python3

have you tried !pip install numpy in hte python Notebook cell?

stetoro
  • 1
  • 3
  • Anaconda and the entire package are already installed on my device. Used it earlier but now I am trying to use it on Jupyter's notebook (webbased). Seems like it is failing to understand any import, including pandas which are installed locally. On another hand, when opening pyton 3.6 (32-bit) and writing "pip install numpy" it is saying "invalid syntax" instead of saying it is already installed for some reason. Is it possible for the issue to be due to the fact that my webbased is Python 3 while my local Python is 3.6? – sammmm Dec 19 '17 at 15:23
  • @sammmm `pip` is a command line utility, it isn't meant to be used inside of python. If you have Anaconda3 properly installed on your device, then you'll be able to import numpy. numpy is one of the libraries in Anaconda – Matt Messersmith Dec 19 '17 at 20:41
0

I had the same problem despite correct version of Python and numpy on my Ubuntu. Then I tried something that worked in Google Colab:

!pip install numpy

After that I was able to import numpy without further complications.