5

I have both Python 2.7 and 3.6 working on my machine. Numpy and Pandas both load, for either version of Python, in the terminal. However, when I try to access them from inside Jupyter notebook, I get the following error messages:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-4ee716103900> in <module>()
----> 1 import numpy as np

ModuleNotFoundError: No module named 'numpy'


ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-af55e7023913> in <module>()
----> 1 import pandas as pd

ModuleNotFoundError: No module named 'pandas'

Here is a screenshot of the problem as well:

enter image description here

If you look in the top right hand corner of the screenshot, you will notice where it says "Python3". I have seen video tutorials on Jupyter where clicking on that button generates a drop down list, allowing users to select alternate versions of Python. However, when I click on that button, nothing happens.

I noticed that a similar question was asked before here:

numpy & pandas 'ModuleNotFoundEror' in Jupyter notebook (Python 3)

However, very little information was provided and no resolution seems to have been found.

Another similar question provided a hint at an answer that was slightly more promising. It suggested running the following code both from terminal and from inside Jupyter, to make sure they match.

import sys; sys.executable

failed to import numpy as np when I worked with jupyter notebook

From terminal using Python 2.7.10>>

import sys; sys.executable
'/usr/bin/python'

From terminal using Python 3.6.1>>

import sys; sys.executable
'/usr/local/bin/python3'

From Jupyter>>

'/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6'
HMLDude
  • 1,547
  • 7
  • 27
  • 47
  • what other imports have you tried? Can you import from the standard library - what about from `IPython`? – Tadhg McDonald-Jensen Jun 22 '17 at 01:15
  • 1
    I can import and run Numpy from either IPython or IPython3, without issue. However, when I run `jupyter notebook` from terminal it does not work. What I just discovered, which is fascinating, is that if I launch Jupyter from Anaconda Navigator it works perfectly. – HMLDude Jun 23 '17 at 02:23

1 Answers1

2

Have you checked this solution: Failure to import numpy in Jupyter notebook ?

In your Jupyter screenshot, you're using a Python 3 kernel. Make sure you have NumPy (and any others you might want to use) installed in your selected Python 3 environment.

risantos
  • 51
  • 2