1

In Jupyter, there is an ImportError:

import numpy as np 

ImportError Traceback (most recent call last)

ipython-input-1-4ee716103900 in module()

----> 1 import numpy as np

ImportError: No mudule named numpy

But in Python, there is no error:

import numpy as np 
Saca
  • 9,665
  • 1
  • 30
  • 42
HONG ZI
  • 31
  • 2
  • 7
  • Please [don't post code as images](http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question) - post your code and error message as text instead. – EJoshuaS - Stand with Ukraine Feb 28 '17 at 05:16

1 Answers1

3

Usually this happens because your python is one Python environment and whatever you're running your notebook with is another. Try running import sys; sys.executable in both environments and seeing whether or not they match. If they don't, that's your problem: whatever jupyter is running in is borrowing numpy from the root environment.

Aleksey Bilogur
  • 3,456
  • 2
  • 25
  • 47
  • Thanks for your answer. i run import sys;sys.executable in the python environment, it displays: /usr/bin/python. but the notebook displays: /bin/python. what can i do to solve it? – HONG ZI Feb 28 '17 at 06:43
  • I recommend installing [anaconda](https://www.continuum.io/downloads) and using their `conda` tooling to get around this. – Aleksey Bilogur Feb 28 '17 at 16:35