Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Numpy and Pandas Not Working in Jupyter Notebook on Mac

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'
like image 461
HMLDude Avatar asked Oct 30 '22 06:10

HMLDude


1 Answers

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.

like image 77
risantos Avatar answered Nov 09 '22 13:11

risantos