Reputation: 31
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
Upvotes: 1
Views: 6722
Reputation: 1
For ubunutu environment in jupyter, run:
import sys; sys.executable
This will display the python location eg
/home/paul/notepad_vm/notepad_vm/bin/python
switch to bash shell
cd /home/paul/notepad_vm/notepad_vm/bin/python
./pip install numpy
switch back to Jupyter, run:
import numpy as np
Upvotes: 0
Reputation: 3846
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.
Upvotes: 3