Skip to content
Advertisement

Jupyter python3 notebook cannot recognize pandas

I am using the Jupyter notebook with Python 3 selected. On the first line of a cell I am entering:

import pandas as pd

The error I get from the notebook is, ImportError: No module named ‘pandas’. How can I install pandas to the jupyter notebook? The computer I launched the Jupyter notebook from definitely has pandas.

I tried doing:

!pip install pandas

And it says it is already installed but for Python 2.7 at the bottom. My script shows it is a Python 3 script at the top though.

When I do echo $PATH in Ubuntu is shows that ‘/home/user/anaconda2/bin’ is on the first entry. I think I may need to change this to be anaconda3?

UPDATE: When I try and launch a Python3 script through jupyter the command line which launched Jupyter gives me the error “ImportError: No module named ‘IPython.paths’. Then there is a timeout waiting for ‘kernel_info’ reply. Additionally, I tried removing anaconda but still experience the same error. I have tried to make so many quick fixes now, that I am not sure what the next step is to get this working.

Advertisement

Answer

As your default python version is 2.x , if you don’t have any emphasis on the python 3.x you can try from the first by the below scripts.

pip install --upgrade pip
pip install jupyter

then in jupyter notebook:

!pip install pandas

The version of notebook will be 2.x. Otherwise install pip3 by the below Linux commands.

sudo apt-get install python3-setuptools
sudo easy_install3 pip

now you can add pandas to the notebook by !pip3 install pandas.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement